本文整理汇总了PHP中Room::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::findOrFail方法的具体用法?PHP Room::findOrFail怎么用?PHP Room::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::findOrFail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($id)
{
$room = Room::findOrFail($id);
$room->location_id = Input::get('location');
$room->name = Input::get('name');
$room->capacity = Input::get('capacity');
$room->save();
Session::flash('message', 'Sukses mengupdate ruangan!');
}
示例2: postUpdate
/**
* Update the specified room in storage.
*
* @param int $id
* @return Response
*/
public function postUpdate($id)
{
$room = Room::findOrFail($id);
$validator = Validator::make($data = Input::all(), Room::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$room->update($data);
return Redirect::action('RoomsController@getIndex');
}
示例3: postUpdateRates
public function postUpdateRates()
{
$rules = ['from_date' => 'required|date_format:Y-m-d|after:' . date('Y-m-d', strtotime('yesterday')), 'to_date' => 'required|date_format:Y-m-d|after:' . date('Y-m-d', strtotime('yesterday')), 'week_day' => 'required', 'rooms' => 'required', 'rate' => 'required|numeric|min:0', 'single_rate' => 'numeric|min:0'];
$validator = Validator::make($data = Input::all(), $rules);
if ($validator->fails()) {
return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()], 400);
//400 - http error code
}
//all ok so get rooms and plans mapping
$weekDays = $data['week_day'];
$errors = [];
$property = Property::findOrFail(Property::getLoggedId());
foreach ($data['rooms'] as $roomId) {
//get room data
$room = Room::findOrFail($roomId);
$depth = 0;
$this->updateChannelRate($room, $property, $data, $data['rate'], $weekDays, $errors, $depth);
}
if (!empty($errors)) {
return Response::json(['success' => false, 'errors' => $errors], 400);
//400 - http error code
}
return Response::json(['success' => true], 200);
//200 - http success code
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
// get the room
$room = Room::findOrFail($id);
// show the edit form and pass the room
return View::make('rooms.edit')->with('room', $room);
}