Skip to content
Advertisement

How to fix “Undefined property: stdClass::$gamme” [closed]

I am new in the Laravel this is my first app. I have 2 tables:

art

-id
-code
-designation
-prix
-qte
-gamme_id

gamme

-id
-type

I have a relation between them

artmodel enter image description here

gamme_model enter image description here

and I want to search article by “code”

search function in the controller enter image description here

The problem is here enter image description here

This is my index file This is my index file

I try to replace
<td>{{ $row->gamme->type }}</td> to <td>{{ $row->gamme_id}}</td>

And it works but I don’t want to see the id of gamme:

its gamme_id but I want the name of gamme

Advertisement

Answer

Can you try this

$data = Art::where('code','LIKE','%'.$search.'%')->paginate(5);
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement