Home > Blockchain >  Laravel Eloquent Trouble
Laravel Eloquent Trouble

Time:10-18

hi guys I got lot of confuse , I made it some relationship with tables but... please help me thx for any helps enter image description here

I got one product table , and realated urun_entity table, urun_entity tables related with atributes color,weight etc etc..

and my urun_entity table looks like

enter image description here

$urun = DB::table('urun_entity')
        ->join('ucolor','urun_entity.id','=','ucolor.id')
        ->join('urun','urun_entity.urun_id','=','urun.id')->get();

I'd try fetch data like this, ucolor id only fetch one data how can I fetch all datas on color tables

Thank you for your help and suggestions.

CodePudding user response:

You must use "urun_entity.ucolor_id" in your "ucolor" join. The correct relationship should be like the following:

$urun = DB::table('urun_entity')
    #### The mistake was in the below line.
    ->join('ucolor','urun_entity.ucolor_id','=','ucolor.id')
    ->join('urun','urun_entity.urun_id','=','urun.id')->get();
  • Related