Ich habe mein Modell wie folgt aus: Das Produkt eine Beziehung mit Land hatLaravel Beziehung eloquent
class Product extends Model
{
public function country()
{
return $this->belongsTo('App\Country','countrie_id');
}
}
Ich habe diese Abfrage in meinem Controller:
$products = Product::where('name', 'LIKE', '%'.$request->search.'%')->get();
Es gibt:
"id": 1,
"categorie_id": 1,
"countrie_id": 1,
"solution_id": 1,
"line_id": 1,
"name": "COLAGEN PREMIUN",
"internal_code": "1321368478978",
"description": "FSDFSDF",
"composition": "colageno de acido citrico",
"benefits": "ayuda a al anemia",
"price": 250,
"price_sale": 500,
"active": 1
Ich würde gerne wissen, wie man den Namen des Landes und nicht die country_id mit dieser Beziehung abrufen kann?