adiss's avatar

Convert array to Eloquent model

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);
    }

0 likes
3 replies
adiss's avatar

Still i cant resolve this ... i coming with .net background and this is easy part i just need something like List .... I tried with method fill but i got only one Notebook... also i search a lot about hydrators in laravel but i cant find anything.

Please or to participate in this conversation.