當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Space::create方法代碼示例

本文整理匯總了PHP中Space::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Space::create方法的具體用法?PHP Space::create怎麽用?PHP Space::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Space的用法示例。


在下文中一共展示了Space::create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register

 public function register(array $input = array())
 {
     $customrules = ['email' => 'required|email|unique:user,email'];
     $input['type'] = isset($input['type']) ? $input['type'] : 'user';
     $input['via'] = isset($input['via']) ? $input['via'] : 'register';
     $input['signup_ref'] = isset($input['signup_ref']) ? $input['signup_ref'] : null;
     $input['ref_code'] = $this->_refCodeGenerator();
     $validation = $this->model->validate($input, $customrules);
     if ($validation->passes()) {
         $user = $this->model->create($input);
         $this->_sendWelcomeMail($input);
         if ($input['signup_ref'] != null) {
             \Space::create(['user_id' => $user->id, 'type' => 'credit', 'nominal' => \Config::get('thankspace.space_credit.signup'), 'keterangan' => 'Space Credit for sign up from link referral']);
         }
         $this->_sendAdminNewCustomerMail($user->id);
         if ($input['via'] != 'admin') {
             $auth = $this->_handleLogin($user->id);
             return $auth;
         } else {
             return true;
         }
     } else {
         $this->setErrors($validation->messages()->all(':message'));
         return false;
     }
 }
開發者ID:rizalafani,項目名稱:thankspace,代碼行數:26,代碼來源:UserRepo.php

示例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;
 }
開發者ID:rizalafani,項目名稱:thankspace,代碼行數:67,代碼來源:OrderRepo.php


注:本文中的Space::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。