You are looking for Hydrators.
https://laracasts.com/discuss/channels/tips/hydrators-in-laravel-5
Let me know how it goes and if you need working code example.
I try to implement search function with this package https://github.com/TomLingham/Laravel-Searchy. When Searchy query is done it return Array data. I dont need array i need Eloquent model becouse with array i cant implement pagination. I try to cast it to Notebook collection but i dont know how to do it. This is what i did and i got this error
Call to undefined method Illuminate\Database\Eloquent\Collection::paginate()
public function laptopiPretraga()
{
$laptopi= new \Illuminate\Database\Eloquent\Collection;
$query = \Input::get('pretragaTxt');
$laptopiSearch = \Searchy::notebooks('modelName', 'graphicCard')->query($query)->get();
foreach ($laptopiSearch as $laptop) {
$laptopi->add(Notebook::findOrFail($laptop->id));
}
$laptopi->paginate(12);
return view('notebook.artikli')->with('laptopi',$laptopi);
}
Please or to participate in this conversation.