skip to Main Content

Laravel – I try build hasmany relation between card and product table . But I can not access products attributes . It shows null

//my controller public function show_card(){ if(Auth::id()) { $id=Auth::user()->id; $cards=Card::with('product_card')->where('user_id','=',$id)->get(); return view('home.show_cart',compact('cards')); } else{ return redirect('login'); } } //product model public function product_card() { return $this->hasMany(Card::class,'product_id','id'); } //card model public function product_card() { return $this->belongsTo(Product::class); } //I want to access product…

VIEW QUESTION
Back To Top
Search