本文整理汇总了PHP中Discount::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Discount::where方法的具体用法?PHP Discount::where怎么用?PHP Discount::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discount
的用法示例。
在下文中一共展示了Discount::where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validation
public function validation($code)
{
$now = new DateTime();
$now->setTimezone(new DateTimeZone('America/Chicago'));
$discount = Discount::where('name', '=', $code)->First();
if (!$discount) {
//retrived data save from API - See API documentation
$data = array('success' => false, 'error' => "Discount code not available.");
return $data;
} else {
$used = $discount->limit - count(Payment::where('promo', '=', $code)->get());
if ($discount->start <= $now->format('Y-m-d') && $discount->end >= $now->format('Y-m-d') && $used > 0) {
//allow only one discount at a single time
Session::forget('discount');
Session::flash('discount', array('percent' => $discount->percent, 'id' => $discount->id));
//retrived data save from API - See API documentation
$data = array('success' => true, 'now' => $now->format('Y-m-d'), 'start' => $discount->start, 'end' => $discount->end);
return $data;
} else {
$data = array('success' => false, 'error' => "Discount code not active or past validation day");
return $data;
}
}
}
示例2: billUpdate
public static function billUpdate($id, $account_id, $for_month, $adjustments_new, $device_cost_new, $discount_new, $other_charges_new, $for_month_last, $update)
{
if (count($for_month_last) != 0) {
$bill = Bill::where('account_id', '=', $account_id)->where('for_month', $for_month_last)->get()->first();
} else {
$bill = Bill::where('account_id', '=', $account_id)->where('for_month', $for_month)->get()->first();
}
// var_dump($bill,$for_month,$account_id);die;
if (count($bill) != 0) {
$bill_now = Bill::where('account_id', '=', $account_id)->where('for_month', $for_month)->first();
if ($for_month_last) {
$previous_balance = ceil($bill->amount_before_due_date);
$last_payment = ceil($bill->amount_paid);
} else {
$previous_balance = ceil($bill->prev_bal);
$last_payment = ceil($bill->last_payment);
}
$amount_paid = PaymentTransaction::where('bill_no', $bill_now->bill_no)->where('account_id', $account_id)->where('status', 'success')->sum('amount');
$account_id = $bill->account_id;
$bill_date = $bill->bill_date;
$bill_start_date = $bill->bill_start_date;
$bill_end_date = $bill->bill_end_date;
$due_date = $bill->due_date;
$security_deposit = $bill->security_deposit;
$status = $bill->status;
if (count($update) != 0) {
$adjust = Adjustment::where('account_id', '=', $account_id)->where('for_month', $for_month)->where('id', '!=', $id)->sum('amount');
$device = DeviceCost::where('account_id', '=', $account_id)->where('for_month', $for_month)->where('id', '!=', $id)->sum('amount');
$other_c = OtherCharges::where('account_id', '=', $account_id)->where('for_month', $for_month)->where('id', '!=', $id)->sum('amount');
$discount = Discount::where('account_id', '=', $account_id)->where('for_month', $for_month)->where('id', '!=', $id)->sum('amount');
$device_cost = $device + $device_cost_new;
$other_charges = $other_c + $other_charges_new;
$discount = $discount + $discount_new;
$adjustments = $adjust + $adjustments_new;
} else {
$device_cost = $bill->device_cost + $device_cost_new;
$other_charges = $bill->other_charges + $other_charges_new;
$discount = $bill->discount + $discount_new;
$adjustments = $bill->adjustments + $adjustments_new;
}
if (count($adjustments_new) != 0) {
$adjustment_update = Adjustment::where('id', $id)->first();
$adjustment_update->is_considered = 'Y';
$adjustment_update->save();
}
if (count($device_cost_new) != 0) {
$device_cost_update = DeviceCost::where('id', $id)->first();
$device_cost_update->is_considered = 1;
$device_cost_update->save();
}
if (count($other_charges_new) != 0) {
$other_charges_update = OtherCharges::where('id', $id)->first();
$other_charges_update->is_considered = 1;
$other_charges_update->save();
}
if (count($discount_new) != 0) {
$discount_update = Discount::where('id', $id)->first();
$discount_update->is_considered = 1;
$discount_update->save();
}
$bill_count = Bill::where('account_id', $account_id)->get();
if ($for_month_last) {
if (count($bill_count) == 1) {
$current_rental = $bill->current_rental;
$onetime_charges = $bill->onetime_charges;
$sub_total = $current_rental;
$service_tax = ceil($sub_total * 0.14);
$plan_name = $bill->cust_current_plan;
$total_charges = ceil($sub_total + $service_tax);
$total_amount = ceil($sub_total + $service_tax - $adjustments + $other_charges - $discount + $device_cost + $onetime_charges);
} else {
$current_rental = $bill_now->current_rental;
$sub_total = $current_rental;
$onetime_charges = $bill_now->onetime_charges;
$service_tax = ceil($sub_total * 0.14);
$plan_name = $bill_now->cust_current_plan;
$total_charges = ceil($sub_total + $service_tax);
$total_amount = ceil($sub_total + $service_tax - $adjustments + $other_charges - $discount + $device_cost);
}
} else {
$current_rental = $bill_now->current_rental;
$onetime_charges = $bill_now->onetime_charges;
$sub_total = $current_rental;
$service_tax = ceil($sub_total * 0.14);
$total_charges = ceil($sub_total + $service_tax);
$plan_name = $bill_now->cust_current_plan;
if (count($bill_count) == 1) {
$total_amount = ceil($sub_total + $service_tax - $adjustments + $other_charges - $discount + $device_cost + $onetime_charges);
} else {
$total_amount = ceil($sub_total + $service_tax - $adjustments + $other_charges - $discount + $device_cost);
}
}
$amount_before_due_date = intval($previous_balance - $last_payment + $total_amount);
$amount_after_due_date = intval($previous_balance - $last_payment + $total_amount);
if ($amount_paid == 0) {
$status = "not_paid";
} else {
if ($amount_before_due_date > $amount_paid) {
$status = "partially_paid";
} else {
//.........这里部分代码省略.........
示例3: postPayment
public function postPayment()
{
$payer = new Payer();
$i = [];
$input = Input::all();
$membership_discount = Session::has('reservation.customerdiscount') ? number_format(Session::get('reservation.customerdiscountprice'), 2) : 0;
$coupon_discount = 0;
$total_discount = 0;
$i['checkin'] = Session::get('reservation')['checkin'];
$i['checkout'] = Session::get('reservation')['checkout'];
$i['total_nights'] = Session::get('reservation')['nights'];
$total_price = 0;
$tax_price = 0;
$item = [];
$payer->setPaymentMethod('paypal');
foreach (Session::get('reservation')['reservation_room'] as $roomKey => $rooms) {
$total_price += $rooms['room_details']['price'] * $i['total_nights'] * $rooms['quantity'];
$room_id = $rooms['room_details']['id'];
$available_rooms = [];
$room_qty = RoomQty::with(array('roomPrice', 'roomReserved' => function ($query) use($i, $room_id) {
$query->where(function ($query2) use($i, $room_id) {
$query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
})->where('status', '!=', 5);
}))->where('room_id', $room_id)->get();
foreach ($room_qty as $available) {
if ($available->roomReserved == '[]') {
$item[$roomKey] = new Item();
$item[$roomKey]->setName($rooms['room_details']['name'])->setDescription("Room \"" . $rooms['room_details']['name'] . "\". P " . $rooms['room_details']['price'] . " per night (" . $i['total_nights'] . " nights)")->setCurrency('PHP')->setQuantity($rooms['quantity'])->setPrice($rooms['room_details']['price'] * $i['total_nights']);
}
}
}
if (isset($input['discountCode'])) {
$discount = Discount::where('code', $input['discountCode'])->first();
if ($discount) {
if ($discount->used == null || $discount->used == '') {
$coupon_discount = $discount->calculateDiscount($total_price, $discount->effect, $discount->effect_type);
$discount->used = date('Y-m-d H:i:s');
$discount->save();
}
}
}
$total_discount = -$membership_discount - $coupon_discount;
$total_price += $total_discount;
Session::put('total_price', $total_price);
if ($membership_discount != 0) {
Session::put('hasMembershipDiscount', $membership_discount);
}
if ($coupon_discount != 0) {
Session::put('hasCouponDiscount', $coupon_discount);
}
$discount1 = new Item();
$discount1->setName('Discount')->setDescription("Reservation Discount")->setCurrency('PHP')->setQuantity(1)->setPrice($total_discount);
array_push($item, $discount1);
$item_list = new ItemList();
$item_list->setItems($item);
$tax_price = $total_price * 0.12;
/*set tax*/
$details = new Details();
$details->setSubtotal($total_price);
/*computing the amout*/
$amount = new Amount();
$amount->setCurrency('PHP')->setDetails($details)->setTotal($total_price);
/*creation of transaction starts here*/
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($item_list)->setDescription('Filigans Hotel Reservation');
$redirect_urls = new RedirectUrls();
$redirect_urls->setReturnUrl(URL::route('payment.status'))->setCancelUrl(URL::route('payment.status'));
$payment = new Payment();
$payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction));
try {
$payment->create($this->_api_context);
} catch (PayPal\Exception\PayPalConnectionException $ex) {
if (\Config::get('app.debug')) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
$err_data = json_decode($ex->getData(), true);
return $err_data;
exit;
} else {
die('Some error occur, sorry for inconvenient');
}
}
foreach ($payment->getLinks() as $link) {
if ($link->getRel() == 'approval_url') {
$redirect_url = $link->getHref();
break;
}
}
// add payment ID to session
Session::put('paypal_payment_id', $payment->getId());
if (isset($redirect_url)) {
// redirect to paypal
return Redirect::away($redirect_url);
}
return Redirect::route('original.route')->with('error', 'Unknown error occurred');
}
示例4: billInfo
function billInfo($bill_no, $account_id, $for_month)
{
$discount = Discount::where('account_id', '=', $account_id)->where('for_month', '=', $for_month)->get();
foreach ($discount as $key => $value) {
$discount_id[] = $value->id;
}
$adjustment = Adjustment::where('account_id', '=', $account_id)->where('for_month', '=', $for_month)->get();
foreach ($adjustment as $key => $value) {
$adjustment_id[] = $value->id;
}
$othercharges = OtherCharges::where('account_id', '=', $account_id)->where('for_month', '=', $for_month)->get();
foreach ($othercharges as $key => $value) {
$othercharges_id[] = $value->id;
}
$devicecost = DeviceCost::where('account_id', '=', $account_id)->where('for_month', '=', $for_month)->get();
foreach ($devicecost as $key => $value) {
$devicecost_id[] = $value->id;
//var_dump($devicecost[]);die;
}
$discount = count($discount);
$adjustment = count($adjustment);
$othercharges = count($othercharges);
$devicecost = count($devicecost);
$maximum = max($discount, $adjustment, $othercharges, $devicecost);
for ($i = 0; $i < $maximum; $i++) {
$bill_info = new Billinformation();
$bill_info->bill_no = $bill_no;
if (!empty($adjustment_id[$i])) {
$bill_info->adjustment_id = $adjustment_id[$i];
$considered = Adjustment::where('id', '=', $adjustment_id[$i])->get()->first();
$considered->is_considered = '1';
$considered->save();
//var_dump($considered);die;
} else {
$bill_info->adjustment_id = 0;
}
if (!empty($discount_id[$i])) {
$bill_info->discount_id = $discount_id[$i];
$considered = Discount::where('id', '=', $discount_id[$i])->get()->first();
$considered->is_considered = 1;
$considered->save();
} else {
$bill_info->discount_id = 0;
}
if (!empty($othercharges_id[$i])) {
$bill_info->other_charges_id = $othercharges_id[$i];
$considered = OtherCharges::where('id', '=', $othercharges_id[$i])->get()->first();
$considered->is_considered = 1;
$considered->save();
} else {
$bill_info->other_charges_id = 0;
}
if (!empty($devicecost_id[$i])) {
$bill_info->device_cost_id = $devicecost_id[$i];
$considered = DeviceCost::where('id', '=', $devicecost_id[$i])->get()->first();
$considered->is_considered = 1;
$considered->save();
} else {
$bill_info->device_cost_id = 0;
}
$bill_info->save();
}
}
示例5: show
/**
* Display the specified resource.
* GET /discounts/{id}
*
* @param int $id
* @return Response
*/
public function show($id)
{
$cpage = 'discount';
$d = Discount::where('id', $id)->first();
if ($d) {
return View::make('adminview.discount.show', compact('cpage', 'd'));
}
}