try
$company = Companies::with('employees')->where('id', $company_id)->paginate(10);
find() executes the query. What is the purpose if Input::get('search') there?
I am trying to add paginate to a query that has a relationship and when I add the pagination I get error Undefined property: Illuminate\Pagination\LengthAwarePaginator::
$company = Companies::with('employees')->find($company_id)->paginate(
$perPage = 10,
Input::get('search')
);
Don't know about the merits of eager-loading like that...
You could make two queries of your own:
$company = Company::find($id);
$employees = $company->employees()
->where('name', 'like', "%{$request->search}%")
->paginate(10);
return view('name.of.view', compact('company', 'employees'));
I don't know really how I feel about a ?page=x query string though... unless you have a route URI like: /company/{id}/employees?
Please or to participate in this conversation.