Laravel LeftJoin where

后端 未结 3 1677
孤独总比滥情好
孤独总比滥情好 2021-01-19 09:55

I have some problems with my eloquent model, where I try to join two different tables in one

Now I have two tables like.

First tables name \"company_saved_cv

3条回答
  •  有刺的猬
    2021-01-19 10:21

    I solve this problem with this code

     $query = Worker::select('workers.name_and_surname', 'workers.id', 'workers.location','company_saved_cv.worker_id')
            ->leftJoin('company_saved_cv', function($leftJoin)use($company_id)
            {
                $leftJoin->on('workers.id', '=', 'company_saved_cv.worker_id');
                $leftJoin->on(DB::raw('company_saved_cv.company_id'), DB::raw('='),DB::raw("'".$company_id."'"));
    
    
            })
    

提交回复
热议问题