dimanche 19 février 2017

Laravel 5 scout

I'm still learning php and laravel framework. I can't get this code working in my controller I instead put them in my view, but that's not what I want. I want to all my logic in the controller but I can't figure it out how to do that.

// in my controller
    public function index(Request $request)
        {

            $error = ['error' => 'No results found, please try with different keywords.'];
            $results = Actor::search($request->get('query'))->get();
            $results->count() ? $results : $error;

            return view('welcome', compact('results', 'request', 'error'));
        }

// in my view
@if($request->has('query'))

@foreach($results as $result)
      
     
@endforeach
@else

   <p> Please Enter a Keyword</p> 



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lwcNgc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire