I am new using laravel and would like to know how to pass the following query to laravel
UPDATE users
INNER JOIN tm_employee ON users.id = tm_employee.UserId
SET users.groupId = ''
WHERE tm_employee.id = ''
I am new using laravel and would like to know how to pass the following query to laravel
UPDATE users
INNER JOIN tm_employee ON users.id = tm_employee.UserId
SET users.groupId = ''
WHERE tm_employee.id = ''
See if it serves you like this:
DB::table('users')
->join('employee', 'users.id', '=', 'employee.UserId')
->where('employee.id','')
->update([ 'employee' => '' ]);
If you are working each of your tables by means of the models of Laravel, you should do the following
On the controller
Here you can invoke the User model in this way
use App\User;
After that, your query should look like this
$data = User::join('employee', 'users.id', '=', 'employee.UserId')
->where('employee.id','')
->update([ 'employee' => '' ]);
Finally, in order for this to work, you must go to the model User
and declare the following
public $timestamps = false;
WHAT HCIE WAS
updated_at
, that is, ignore it update
method under the key = > value format