Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hjortur17's avatar

Update exiting booking

Hi, how can I update many bookings in one method? I'm finding bookings where email is the same as logged in user and I want to add the id of that user into user_id column.

I tried $bookings->save(), but that didn't work. Any ideas?

public function getBookings()
	{
		$bookings = Booking::where('email', '=', \Auth::user()->email)->get();

		if (request()->wantsJson()) {
			return $bookings;
		}

		return $bookings;
	}
0 likes
3 replies
Sinnbeck's avatar
		Booking::where('email', '=', \Auth::user()->email)->update($arrayOfUpdateData);
hjortur17's avatar

I don't understand. What should be in the $arrayOfUpdateData?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

What would you like to update? Lets say you want to change the statuscolumn to 0

Booking::where('email', '=', \Auth::user()->email)->update(['status' => 0]);

Please or to participate in this conversation.