mercredi 29 novembre 2017

Laravel PHP : How to get Specific Column ID when we apply joins on 3 tables?

I want to get the Rating table ID , but in my jason then will give me the attributes table id when we apply this joins, MY QUERY:

$search = \Request::get('q');
    $u_id = User::find($id);

        $records = DB::table('ratings')->where('user_id' , $id)-
 >where('user_id' , $id)->where(function($q) use ($search){
             $q->where('attribute' , 'like' , '%' .$search. '%');
             $q->orwhere('score' , 'like' , '%' .$search. '%');
             $q->orwhere('attrtype' , 'like' , '%' .$search. '%');
        })
        ->join('users','ratings.user_id','=','users.id')->join('attributes' 
, 'attributes.id' , '=' ,'ratings.attribute_id' )->Paginate(5);
dd($records); 
return view('employee.show',compact('records' , 'u_id' , 'search')); 

After this we Get the ID of Attribute table ,Like That

But we get the Rating tables ID , Thanks Developers in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ikAKYC
via IFTTT

Aucun commentaire:

Enregistrer un commentaire