本文整理汇总了PHP中Reservation::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::where方法的具体用法?PHP Reservation::where怎么用?PHP Reservation::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command
*
* @return void
*/
public function fire()
{
// check if the provided user exists
$user = User::where('username', '=', $this->option('user'))->first();
if (!isset($user)) {
$this->comment("This user don't exist.");
return;
}
// check if the provided reservation exists and delete it
$reservation = Reservation::where('id', '=', $this->argument('id'))->where('user_id', '=', $user->id)->first();
if (isset($reservation)) {
$reservation->delete();
$this->info("Reservation '{$reservation->id}' has been deleted.");
} else {
$this->comment("This reservation do not exist.");
}
return;
}
示例2: reserve_post
public function reserve_post($id)
{
// GET THE LAST RESERVATION
$last_user_reservation = Reservation::where('user_id', Sentry::getUser()->id)->orderBy('created_at', 'desc')->first();
if (!is_null($last_user_reservation)) {
$current_time = time();
$last_user_reservation_time = strtotime($last_user_reservation->created_at);
$interval = abs($current_time - $last_user_reservation_time) / 3600;
if ($interval < 15) {
return Redirect::to('clients')->with('info', 'You must wait 15 hours before you can reserve again.');
}
}
if (is_null(Property::find($id))) {
return Redirect::to('properties');
}
$monitoring = Monitoring::where('block', Input::get('block'))->where('lot', Input::get('lot')) - first();
if (!is_null($monitoring) && $monitoring->status == false) {
return Redirect::to('clients')->with('info', 'This slut is not available sorry.');
}
$rules = array('total_contract_price' => 'required', 'reservation_fee' => 'required', 'downpayment' => 'required', 'equity' => 'required', 'total_months' => 'required', 'monthly_fee' => 'required', 'agent_id' => 'required', 'terms' => 'required', 'block' => 'required|numeric', 'lot' => 'required|numeric');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('clients/reserve/' . $id)->withInput()->withErrors($validator);
} else {
$property = Property::find($id);
$user = $this->user;
// 0. CHANGE PROPERTY STATUS TO 0
$downpayment = intval(Input::get('downpayment')) / 100 * $property->price;
$equity = $property->price - $downpayment - $property->reservation_fee;
$total_months = intval(Input::get('total_months'));
// 1. SAVE TO THE DATABASE
$reservation = new Reservation();
$reservation->property_id = $id;
$reservation->user_id = $this->user->id;
$reservation->agent_id = Input::get('agent_id');
$reservation->total_contract_price = intval(Input::get('total_contract_price'));
$reservation->downpayment = $downpayment;
$reservation->reservation_fee = $property->reservation_fee;
$reservation->block = Input::get('block');
$reservation->lot = Input::get('lot');
// LOANABLE AMOUNT
$reservation->equity = $equity;
$reservation->total_months = $total_months;
$reservation->monthly_fee = $equity / $total_months;
$reservation->terms = Input::get('terms');
//$reservation->unit_type = Input::get('unit_type');
$reservation->save();
// 2. NEW TRANSACTION
$transaction = new Transaction();
$transaction->reference_number = date('Ymd') . '-' . strtoupper(str_random(5));
$transaction->property_id = $id;
$transaction->user_id = $this->user->id;
$transaction->reservation_id = $reservation->id;
$transaction->status = 'Pending';
$transaction->amount = $property->reservation_fee;
$transaction->remarks = "Property Reservation";
$transaction->save();
// UPDATE MONITORING
DB::table('monitorings')->where('block', Input::get('block'))->where('lot', Input::get('lot'))->update(array('status' => false));
// 3.GENERATE INVOICE
$x = View::make('admin.transactions.show', compact('transaction', 'user', 'property'));
$pdf = storage_path() . '/invoices/' . $transaction->reference_number . '.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html($x);
$dompdf->render();
$output = $dompdf->output();
@file_put_contents($pdf, $output);
// 3.1 GENERATE RESERVATION INFORMATION PDF
$y = View::make('admin.reservations.pdf', compact('transaction', 'user', 'reservation', 'property'));
$res = storage_path() . '/reservations/reservation-' . $transaction->reference_number . '.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html($y);
$dompdf->render();
$output = $dompdf->output();
@file_put_contents($res, $output);
// 4. EMAIL DEVELOPER,ADMIN AND BUYER
$admin = User::find(1);
$developer = $property->developer;
$data['transaction'] = $transaction;
Mail::send('mails.default', $data, function ($message) use($transaction, $pdf, $developer, $admin, $res) {
$user = Sentry::getUser();
$message->to($user->email)->subject("Property Reservation Notification");
$message->to($developer->email)->subject("Property Reservation Notification");
$message->to($admin->email)->subject("Property Reservation Notification");
$message->attach($pdf);
$message->attach($res);
});
return Redirect::to('clients')->with('success', 'Your reservation has been sent to administrator for approval.');
}
}
示例3: reservations
public function reservations($id)
{
$this->_exists($id);
$user = User::find($id);
$reservations = Reservation::where('user_id', $id)->get();
return View::make('admin.reservations.index', compact('reservations', 'user'));
}
示例4: messages
public function messages()
{
$reservation = Reservation::where('status', '=', 'Payment Pending')->orWhere('status', '=', 'Half Paid')->get();
if (!$reservation) {
return Redirect::back()->withErrors('Could not find reservation');
}
return View::make('admin.messages', compact('reservation'));
}
示例5: getCancel
/**
* Cancel a reservation by code.
* @param Cluster $cluster
* @param string $code
*/
public function getCancel(Cluster $cluster, $code)
{
// Get the reservation object
$reservation = Reservation::where('code', $code)->first();
if ($reservation == null) {
if ($reservation == null) {
return View::make('cancelled');
}
}
// Delete the reservation
Reservation::where('code', $code)->delete();
// Show some HTML
return View::make('cancelled');
}