本文整理汇总了PHP中Property::getLoggedId方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::getLoggedId方法的具体用法?PHP Property::getLoggedId怎么用?PHP Property::getLoggedId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property::getLoggedId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIndex
/**
* Display a listing of the resource.
* GET /reservations
*
* @return Response
*/
public function getIndex()
{
$execResult = ['updated' => 0, 'created' => 0, 'bookings' => 0, 'cancelled' => 0, 'not_mapped' => 0];
$propertiesChannels = PropertiesChannel::where('property_id', Property::getLoggedId())->get();
foreach ($propertiesChannels as $channelSettings) {
Log::debug($channelSettings);
$channel = ChannelFactory::create($channelSettings);
$result = $channel->getReservations();
Log::debug($result);
if ($result['reservations']) {
foreach ($result['reservations'] as $reservation) {
$reservation['channel_id'] = $channelSettings->channel_id;
$reservation['property_id'] = $channelSettings->property_id;
$resModel = Reservation::getByKeys($channelSettings->channel_id, $channelSettings->property_id)->where('res_id', $reservation['res_id'])->first();
if (isset($reservation['cc_details']) && !empty($reservation['cc_details'])) {
$reservation['cc_details'] = Crypt::encrypt($reservation['cc_details']);
}
switch ($reservation['status']) {
case 'cancelled':
if ($resModel) {
$resModel->status = 'cancelled';
if ($reservation['res_cancel_fee']) {
$resModel->res_cancel_fee = $reservation['res_cancel_fee'];
}
$resModel->cancelled_at = $resModel->freshTimestamp();
$resModel->save();
$execResult['cancelled']++;
//TODO: send email about cancellation
}
break;
case 'booked':
$needAddRooms = true;
if ($resModel) {
if (isset($reservation['modified']) && $reservation['modified']) {
$resModel->update($reservation);
$execResult['updated']++;
$resModel->bookings()->delete();
//TODO: send email about modification
} else {
$needAddRooms = false;
}
} else {
$resModel = Reservation::create($reservation);
$execResult['created']++;
}
if ($reservation['rooms'] && $needAddRooms) {
foreach ($reservation['rooms'] as $room) {
$room['reservation_id'] = $resModel->id;
$room['channel_id'] = $reservation['channel_id'];
$room['property_id'] = $reservation['property_id'];
$mapping = InventoryMap::getMappedRoom($channelSettings->channel_id, $channelSettings->property_id, $room['inventory'], isset($room['plan']) ? $room['plan'] : null)->first();
if ($mapping) {
$room['room_id'] = $mapping->room_id;
} else {
$execResult['not_mapped']++;
//TODO: send email about NOT MAPPED ROOM
}
Booking::create($room);
$execResult['bookings']++;
}
}
break;
}
if ($resModel && $resModel->id) {
$type = $resModel->status;
if ($type != 'cancelled' && $resModel->modified) {
$type = 'modify';
}
$channel->setReservationConfirmation($resModel->id, $resModel->res_id, $type);
}
}
}
}
return View::make('index', compact('execResult'));
}
示例2: 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
}
示例3: getDestroy
/**
* Remove the specified propertieschannel from storage.
*
* @param int $channelId
* @return Response
*/
public function getDestroy($channelId)
{
PropertiesChannel::where(['channel_id' => $channelId, 'property_id' => Property::getLoggedId()])->delete();
return Redirect::action('PropertiesChannelsController@getIndex');
}
示例4: postMap
/**
* Update the specified room in storage.
*
* @return Response
*/
public function postMap()
{
$validator = Validator::make($data = Input::all(), InventoryMap::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$data['property_id'] = Property::getLoggedId();
InventoryMap::getByKeys($data['channel_id'], $data['property_id'], $data['room_id'])->delete();
//get inventory room name
if ($data['code'] && $data['plans']) {
$inventory = Inventory::getByKeys($data['channel_id'], $data['property_id'], $data['code'])->first();
if ($inventory) {
$preparedData = ['name' => $inventory->name, 'room_id' => $data['room_id'], 'inventory_code' => $data['code'], 'channel_id' => $data['channel_id'], 'property_id' => $data['property_id']];
foreach ($data['plans'] as $planCode) {
$plan = InventoryPlan::getByKeys($data['channel_id'], $data['property_id'], $planCode)->first();
if ($plan) {
$preparedData['plan_code'] = $plan->code;
$preparedData['plan_name'] = $plan->name;
InventoryMap::create($preparedData);
}
}
}
}
return Redirect::action('RoomsController@getIndex');
}