Reputation: 37
I want to only select one column from the database then update only that one column
DB::table('available_rooms')
->where('roomTypeID', '=', $request->session()->get('room_type'))->first()
->update(['isAvailable'=> 0]);
With this I'm getting an error
Call to undefined method stdClass::update()
Upvotes: 0
Views: 76
Reputation: 26
You may try this:
Post::where('id', $id)->update(array('title' => 'asdasd'));
Upvotes: 0
Reputation: 1583
Eloquent style
Create model if you don't created:
AvailableRoom::where('roomTypeID', '=', $request->session()->get('room_type'))
->update(['isAvailable'=> 0])
Upvotes: 1
Reputation: 2416
Use limit()
method instead of first()
:
DB::table('available_rooms')
->where('roomTypeID', '=', $request->session()->get('room_type'))->limit(1)
->update(['isAvailable'=> 0]);
Upvotes: 0