update using eloquent in laravel code example
Example 1: update or create laravel
$user = User::updateOrCreate(['name' => request()->name], [
'foo' => request()->foo
]);
Example 2: eloquent update row response
DB::table('users')
->where('id', 1)
->update(['votes' => 1]);
Example 3: update query in laravel eloquent
$data = DB::table('cart')
->where('crt_id', $id)
->update(['crt_status' =>'0']);
Example 4: laravel find query
use App\Models\Destination;
use App\Models\Flight;
return Destination::addSelect(['last_flight' => Flight::select('name')
->whereColumn('destination_id', 'destinations.id')
->orderBy('arrived_at', 'desc')
->limit(1)
])->get();