本文整理汇总了PHP中Space::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Space::where方法的具体用法?PHP Space::where怎么用?PHP Space::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Space
的用法示例。
在下文中一共展示了Space::where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: referral
/**
* Referral feature
*/
public function referral()
{
$userRepo = app('UserRepo');
if (Auth::user()->ref_code == null || Auth::user()->ref_code == '') {
$userRepo->saveRefCodeCustomer();
return Redirect::route('user.referral');
}
return View::make('user.referral')->with(['space_credit' => $userRepo->getCustomerSpaceCredit(), 'customer_join' => $userRepo->getCustomerJoinReferral(), 'space' => Space::where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->get()]);
}
示例2: GetInvoiceAlmostExpired
/**
* Get Storage Query, for get available storage in whare house
* and create new invoice for almost expired storage period,
* send mail and return stuff. this function processed with cron job
*
* @return array $data
*/
public function GetInvoiceAlmostExpired()
{
$interval_info = [-7, -3, 0, 1];
$interval_returned = 3;
$orderPayments = $this->_GetStorages()->where('order.is_returned', 0)->where('payment_1.status', 2)->where('order_schedule.status', 1)->whereNull('order_stuff.return_schedule_id')->having('expired_on', '>=', $interval_info[0])->get();
$data = $this->_getInvoiceInfo($orderPayments);
foreach ($data as $d) {
$temp = $d;
if (in_array($temp['expired_on'], $interval_info)) {
$lunas = false;
// langsung lunas
// cek, apakah sudah punya invoice baru apa tidak. jika tidak, buatkan !
if ($temp['next_invoice'] == null) {
// ambil space credit user_id
$space_credit = app('UserRepo')->getCustomerSpaceCredit($temp['user_id']);
// ambil total biaya
$totalBiaya = getTotalFromCountStuff($temp['stuff']);
// ambil input new_invoice_input ( order_payment )
$newPayment = $temp['new_invoice_input'];
if ($space_credit != 0) {
if ($space_credit >= $totalBiaya) {
$newPayment += ['space_credit_used' => $totalBiaya, 'status' => '2'];
$lunas = true;
} else {
$newPayment += ['space_credit_used' => $space_credit];
}
}
// buat order baru
$newInvoice = $this->_save_orderPayment($temp['order_id'], $newPayment);
$temp['next_invoice'] = $newInvoice->code;
$temp['new_invoice'] = $newInvoice;
// insert space debet jika $space_credit_used != 0
if ($newInvoice->space_credit_used != 0) {
\Space::create(['user_id' => $temp['user_id'], 'type' => 'debet', 'nominal' => $newInvoice->space_credit_used, 'keterangan' => 'Credit used for purchases invoice #' . $newInvoice->code]);
}
}
if ($lunas) {
// kirim email langsung lunas
$this->_sendRecurringInvoiceLunasMail($temp);
} else {
// kirim email invoice expired & invoice baru
$this->_sendRecurringInvoiceMail($temp);
}
} elseif ($temp['expired_on'] == $interval_returned) {
// lakukan pengembalian barang
$returnScheduleInput = ['user_id' => $temp['user_id'], 'order_id' => $temp['order_id'], 'return_date' => \Carbon\Carbon::parse($temp['expired_date'])->addDays(4)->format('Y-m-d'), 'return_time' => '08:00am - 10:00am', 'stuffs' => explode(',', implode(',', array_column($temp['stuff'], 'ids'))), 'city_id' => '', 'other_address' => '', 'status' => 0];
$this->createReturnSchedule($returnScheduleInput);
$_newInvoice = $temp['new_invoice'];
//hapus invoice baru yang dibuat
\OrderPayment::where('code', $_newInvoice->code)->delete();
// cek apakah invoice baru menggunakan space credit, jika iya, hapus space debet nya untuk invoice ini.
if ($_newInvoice->space_credit_used != 0) {
\Space::where('keterangan', 'like', '%#' . $_newInvoice->code . '%')->delete();
}
// kirim email pengembalian barang
$this->_sendRecurringInvoiceKirimBarangMail($temp);
}
}
return $data;
}