मैं एक विशिष्ट उत्पाद प्राप्त करने के लिए एलोक्वेंट का उपयोग करने की कोशिश कर रहा हूं जिसमें brand_id
कॉलम है जो brands
तालिका में मानचित्र करता है, brand
सरणी खाली वापस आ रही है।लार्वेल एलोक्वेंट के साथ() -> वापस लौटना
क्या यहां कुछ भी स्पष्ट है जिसे बदलने की जरूरत है?
$product = Product::with('images')->with('brand')->select($fields)->where('display', '=', 1)->find($id);
// उत्पाद मॉडल
class Product extends Eloquent {
...
public function brand()
{
return $this->belongsTo('Brand');
}
// ब्रांड मॉडल
class Brand extends Eloquent {
...
public function products()
{
return $this->hasMany('Product');
}
क्या आपने इसे चेक किया है: $ brand = $ product-> brand(); ? – num8er
'फ़ील्ड' चर में कौन से फ़ील्ड हैं? –