tonydavis1995's avatar

Convert SQL Query result into array of strings and use whereIn for ids

 public function getDesk(Request $request)


    {
        $uid = $request -> user()->id;

        

      
      $jobids = DB::select( DB::raw("SELECT DISTINCT jobid FROM jhe WHERE empid = :empidd ORDER BY created_at" ), array('empidd' => $uid,));

    


        $jobs = Job::where(function($query) use ($jobids)
            {

                return $query->whereIn('id', $jobids);
            })
        ->orderBy('created_at','desc')
        ->get();
       
        



        return view('employee.desk',['jobs' => $jobs]);
    }
}

error getting:

ErrorException in Str.php line 305: Object of class stdClass could not be converted to string

on dd($jobids); (https://image.ibb.co/mV1n7a/sss.png)

what i need to use the job ids obtained from sql query result to return jobs having those job id

0 likes
0 replies

Please or to participate in this conversation.