Reputation: 253
I have a table : Profile Table has one foreign key and primary key. I want to update row based on two condition . Like : where ( id == 1 and user == 'admin')
How to use two para meter in update query using eloquent.
Upvotes: 5
Views: 13059
Reputation: 862
you can do this by make the following:
ModelName::where(['id'=>1,'user'=>'admin'])
->update(['column_name'=>'value',.....]);
Upvotes: 17
Reputation: 54
Try it
$obj=ModelName::where('id','=',1)->where('user','=','admin')->first();
if(count($obj) == 1){
$obj->column_name=value;
$obj->save();
}
Upvotes: 0