0
I have manipulated the BD data with the creation of Models, but in my latest project I’m tending to make use of Query Builder, but it’s going wrong.
I would like to understand what is missing so that the code works perfectly. To start I declared the stabbing use DB in my controller. Here is the code.
public function putente(Request $request)
{
$putentes = DB::table('utentes')->where('nome',$request->get('putente'))->orWhere('bi_n', $request->get('putente'))->get();
if(count($putentes)>0)
{
return view('home', ['putentes'=>$putentes]);
}
}
In my view I try to take the data this way
{{$putentes->nome}}
But this returning error
ErrorException in db040389b09b4e77a2f0e7fafa9a269acda44af2.php line 45:
Trying to get property of non-object (View: C:\xampp\htdocs\admc\resources\views\home.blade.php)
Is there a problem using Query Builder instead of Models in projects?
Thanks for the contribution, but I solved the question by adding the first() method at the end of the query, so it returns only one line and not a set of lines in the form of Array.
– Francisco Bizi