I have a resource controller. The route for that is like this-
Route::resource('branches/{branch_id}/employees', 'EmployeeController');
The problem is in every method I need to pass the branch variable to the view.
public function index($branch_id){
$branch = Branch::find($branch_id);
$employees = Employee::orderBy('created_at', 'desc')->get();
return view('employees.index', compact('branch', 'employees'));
}
Is there any way that I can pass the branch variable to each view returned through this controller?
@Sapnesh Naik Its not a duplicate as I need to manipulate the branch in each function.