WhereIN from model function laravel -


  • hi there, please try make small application in laravel, , same issues hasmany relation-ship : client model , model have multi affiliate code:

    class client extends model {      public function affiliates()     {         return $this->hasmany('app\client');     } 

    .....

and problem :

i try select project list specifique client , affiliate together

$filiale_client_ids = db::table('clients')                     ->where('client_id',$request->get('client_id'))                     ->select('id')                     ->get();   $projects = project::withtrashed()         ->where('client_id',$request->get('client_id'))         ->wherein('client_id', $filiale_client_ids); 

and doesn't make sense, thank you.

i fix problem, , share solution:

$filiale_client_ids= client::find($request->get('client_id'))->affiliates->pluck('id');          $project = project::withtrashed()         ->where('client_id',$request->get('client_id'))         ->orwherein('client_id', $filiale_client_ids)         ->get(); 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -