jeudi 20 juillet 2017

can`t access laravel Query Builder result from view

I can`t access the values from this variable $post from controller:

in blade view:

@foreach($post as $p)
          <div class="col-md-3">
                 <div class="boxpromo">
                    <h4></h4>
                    <p></p>
                    <div class="price">
                        <div class="data"></div>
                   <div class="cost"></div>
                 </div>
               </div>
           </div>
  @endforeach

In controller i have:

public function postSearchTransport(Request $request, Post $post){
...
// create a new query builder
        $post = $post->newQuery();

        // add some filters from the user in the search query
        if($request->has('searchWord')){
            $post->where('title', 'LIKE', '%'.$request->input('searchWord').'%');
        }
...//more filters
$post->paginate(5);
return view('searchVehicle.showSearchPost')->with('post', $post);
}

What i did wrong? I should be able to access in the view all the values from the query result, but i can`t this way.

Should i convert that $post std object from controller into an array then return it to the view???



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

Aucun commentaire:

Enregistrer un commentaire