I want to return the data of Charge
instance instead of User
, for that i am trying to use joins ,can you please help me to acheive this thing
$id=Charge::whereNotNull('created_by')->get('created_by')->toArray();
foreach($id as $name){
$id[] = $name['created_by'];
}
return $v=User::whereIn('id',$id)->where('username',$request->data)->get();
}
for this i am trying to use left join , relationship available between created_by and id (I am trying to convert above queries into single query)
$v=Charge::whereNotNull('created_by')->leftJoin('User',function($join){
$join->on('Charge.created_by','=','User.id');
})->get();