mardi 26 juin 2018

passing function value in laravel query

I want to passing function values in laravel query.I have a function getUser which returns $val=['nithya.sreeraman','jaivignesh.parthiban','aadhil.ahmed','aarthe.sathyanaraya','abdulamjad.babu','khaja.hussain']

function getUser() {
 $reportees=array();
 try{
 global $reportee_list;
 global $reportees; 
 /*stuff*/ 
  return $reportees;
 }
 catch{
 }
}
$val=getUser();
// print_r($val); 
 $program=DB::table('project')->whereIN('owner',$val)->pluck('project.name','project.code'); //I want to pass  $val in this query 

I'm getting error

Invalid argument supplied for foreach()

while passing $val.but executed when I pass as

 $program=DB::table('project')->whereIN('owner',['nithya.sreeraman','jaivignesh.parthiban','aadhil.ahmed','aarthe.sathyanaraya','abdulamjad.babu','khaja.hussain'])->pluck('project.name','project.code');

how to pass function value in laravel query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire