5

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.

Sarita Sharma
  • 253
  • 2
  • 8
  • 19
  • 1
    Possible duplicate of [How to create multiple where clause query using Laravel Eloquent?](https://stackoverflow.com/questions/19325312/how-to-create-multiple-where-clause-query-using-laravel-eloquent) – Devon Bessemer Jul 02 '18 at 20:18

2 Answers2

17

you can do this by make the following:

ModelName::where(['id'=>1,'user'=>'admin'])
->update(['column_name'=>'value',.....]);
Mr. Perfectionist
  • 2,605
  • 2
  • 24
  • 35
ali
  • 832
  • 6
  • 11
0

Try it

$obj=ModelName::where('id','=',1)->where('user','=','admin')->first();
if(count($obj) == 1){
   $obj->column_name=value;
   $obj->save();
}