@zafeer Please place your DB::table code inside a code block.
It looks like you are not defining e but this could just be markdown messing up your code. Let me know.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to update data of column completed after comparing the data of two columns employee_id & job_id from each of the tables resignation and request, What code do need to write in my laravel controller
*request table:*
| ID | employee_id | job_id | completed |
| ---- | ------------ |--------|-----------|
| 1 | 1 | 1 | 1 |
| 2 | 2 | 4 | 0 |
| 3 | 3 | 7 | 0 |
| 4 | 1 | 6 | 0 |
*resignation table:*
| ID | employee_id | job_id | action |
| ---- | ------------ |--------|-----------|
| 1 | 1 | 1 | 1 |
| 2 | 1 | 6 | 0 |
| 3 | 2 | 9 | 0 |
I have written the below code in my controller but it is not working
DB::table('request as q') ->leftJoin('employee as e','q ̣employee_id','=','e ̣ID') ->leftJoin('resignation as r','e ̣ID','=','r ̣employee_id') ->where('r ̣ID',$ID)->where('r ̣job_id','=','q ̣job_id') ->update([ 'q ̣completed' => '1' ]);
If I am understanding you correctly:
Request::join('resignation', function ($join) {
$join->on('request.job_id', '=', 'resignation.job_id');
$join->on('request.employee_id', '=', 'resignation.employee_id');
})->where('request.id', '=', $ID)->update(['completed' => 1]);
Please or to participate in this conversation.