本文整理汇总了PHP中app\models\Customer类的典型用法代码示例。如果您正苦于以下问题:PHP Customer类的具体用法?PHP Customer怎么用?PHP Customer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Customer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreateMultipleModels
public function actionCreateMultipleModels()
{
$models = [];
if (isset($_POST['Customer'])) {
$validateOK = true;
foreach ($_POST['Customer'] as $postObj) {
$model = new Customer();
$model->attributes = $postObj;
$models[] = $model;
$validateOK = $validateOK && $model->validate();
}
// All models are validated and will be saved
if ($validateOK) {
foreach ($models as $model) {
$model->save();
}
// Redirect to grid after save
return $this->redirect(['grid']);
}
} else {
for ($k = 0; $k < 3; $k++) {
$models[] = new Customer();
}
}
return $this->render('createMultipleModels', ['models' => $models]);
}
示例2: checkSaleCredential
private function checkSaleCredential(Customer $customer, $sale)
{
if ($sale = '1元专区') {
return !$customer->hasPurchesedOneSale();
}
return true;
}
示例3: save
function save(array $params)
{
$response = new ResponseEntity();
DB::transaction(function () use(&$response, $params) {
$user = User::find(Auth::user()->id);
$product = Product::find($params['product_id']);
$cust = new Customer();
$cust->first_name = $params['customer']['first_name'];
$cust->last_name = $params['customer']['last_name'];
$cust->phone_number = $params['customer']['phone_number'];
$custCreated = $cust->save();
if ($custCreated && $product && $user) {
$sale = new Sale();
$sale->user_id = $user->id;
$sale->sale_status_id = Config::get('constants.sale_status.sale');
$sale->product_id = $product->id;
$sale->customer_id = $cust->id;
$sale->date_sold = Carbon::createFromFormat('m/d/Y', $params['date_sold'])->toDateString();
$sale->remarks = isset($params['remarks']) ? $params['remarks'] : '';
$sale->order_number = $params['order_number'];
$sale->ninety_days = isset($params['ninety_days']) ?: 0;
$ok = $sale->save();
if ($ok) {
$ok = $this->setIncentive($sale->user_id, $sale->date_sold);
$response->setMessages($ok ? ['Sale successfully created!'] : ['Failed to create sale!']);
$response->setSuccess($ok);
} else {
$response->setMessages(['Failed to create sale!']);
}
} else {
$response->setMessages(['Entities not found']);
}
});
return $response;
}
示例4: actionPayment
public function actionPayment()
{
if (\Yii::$app->session->has('customer')) {
$modelCustomer = new Customer();
$infoCustomer = $modelCustomer->getInformation($_SESSION['customer']);
$modelOrder = new Order();
$modelOrderDetail = new OrderDetail();
$modelProduct = new Product();
$ids = array();
foreach ($_SESSION['cart_items'] as $id => $quantity) {
array_push($ids, $id);
}
$products = $modelProduct->getWithIDs($ids);
if (\Yii::$app->request->post()) {
$modelOrder->load(\Yii::$app->request->post());
$modelOrder->save();
$orderId = $modelOrder->id;
foreach ($_SESSION['cart_items'] as $id => $quantity) {
$unitPrice = $modelProduct->getPrice($id) * $quantity;
\Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute();
}
\Yii::$app->session->remove('cart_items');
return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']);
} else {
return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]);
}
} else {
$this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']);
}
}
示例5: actionCreateMultipleModels
public function actionCreateMultipleModels()
{
$models = [];
$OK = true;
if (isset($_POST['Customer'])) {
foreach ($_POST['Customer'] as $postObj) {
$customer = new Customer();
$customer->attributes = $postObj;
$isValid = $customer->validate();
$OK = $OK && $isValid;
$models[] = $customer;
}
if ($OK) {
foreach ($models as $model) {
$model->save();
}
$this->redirect('customers/grid');
}
} else {
for ($i = 0; $i < 3; $i++) {
$models[] = new Customer();
}
}
return $this->render('createMultipleModels', compact('models'));
}
示例6: create
/**
* O método precisa informar uma lista de produtos
* @return {view}
*/
public function create()
{
$stocks = Stock::all();
$customers = Customer::all();
$employees = Employee::all();
return view('pages.new_sale', ['stocks' => $stocks, 'customers' => $customers, 'employees' => $employees]);
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$role = Role::where('name', 'admin')->first();
$customer = Customer::create(['name' => 'test']);
$customer->user()->save(new User(['email' => 't@t.test', 'password' => bcrypt('testing')]));
$customer->user->assignRole($role);
}
示例8: index
public function index(){
$data = [
'auth'=>false,
'recentAdded'=>Customer::orderBy('created_at', 'desc')->take(5)->get()
];
return view('home', $data);
}
示例9: getSearch
public function getSearch(Request $request)
{
$q = $request->get('q');
$limit = $request->get('limit', 5);
$customers = Customer::where('mobile_phone', 'like', $q . '%')->with('addresses')->paginate($limit);
return $customers;
}
示例10: approveApplication
public function approveApplication(Request $request)
{
$shop_card_application_id = $request->input('require_id');
$application = ShopCardApplication::find($shop_card_application_id);
$customer = Customer::find($application->customer_id);
$card_type = $application->cardType;
try {
\DB::transaction(function () use($application, $customer, $card_type) {
$customer_rows = \DB::table('customers')->where('id', $customer->id);
$customer_rows->lockForUpdate();
$customer_row = $customer_rows->first();
if ($customer_row->beans_total < $card_type->beans_value * $application->amount) {
throw new NotEnoughBeansException();
}
$cards = \DB::table('shop_cards')->where('card_type_id', '=', $card_type->id)->whereNull('customer_id')->limit($application->amount);
$cards->lockForUpdate();
if ($cards->count() < $application->amount) {
throw new CardNotEnoughException();
}
$customer->minusBeansByHand($application->amount * $card_type->beans_value);
$cards->update(['customer_id' => $customer->id, 'bought_at' => Carbon::now()]);
$application->update(['authorized' => true]);
return true;
});
} catch (CardNotEnoughException $e) {
return '相应卡片不足,无法继续。';
} catch (NotEnoughBeansException $e) {
return '用户迈豆不足!';
}
return "操作成功!";
}
示例11: index
public function index()
{
$c = Customer::get();
$bankaccount = Bankaccount::joining();
$voucher = Voucher::orderBy('id', 'desc')->where('type', 5)->take(10)->get();
return view('contravouchar', compact('bankaccount', 'c', 'voucher'));
}
示例12: detail
/**
* Display a customer
*
* @return Response
*/
public function detail($id = null)
{
$result = \App\Models\Customer::id($id)->with(['sales', 'myreferrals', 'myreferrals.user'])->first();
if ($result) {
return new JSend('success', (array) $result->toArray());
}
return new JSend('error', (array) Input::all(), 'ID Tidak Valid.');
}
示例13: report
public function report()
{
$s = Supplier::get();
$c = Customer::get();
$bankaccount = Bankaccount::joining();
$voucher = Voucher::orderBy('id', 'desc')->take(10)->get();
return view('ledger', compact('bankaccount', 'c', 's', 'voucher'));
}
示例14: actionLogin
public function actionLogin()
{
$model = new Customer();
if ($model->load(Yii::$app->request->post())) {
$request = Yii::$app->request->post('Customer');
$username = $request['username'];
$password = $request['password'];
if ($model->checkLogin($username, $password)) {
$customerName = $model->getName($username);
Yii::$app->session->set('customer', $customerName);
$this->redirect(['site/index']);
} else {
$this->redirect(['login', 'error' => 'Tên đăng nhập hoặc mật khẩu không đúng!']);
}
}
return $this->render('login', ['model' => $model]);
}
示例15: test
public function test()
{
$customer = Customer::where('openid', 'oUS_vt3J8ClZx4q1wmx6VBJ1KfwQ')->firstOrFail();
$end = new \DateTime(Carbon::now()->format('Y-m'));
$begin = new \DateTime($customer->created_at->format('Y-m'));
$month = \Helper::getDatePeriod($begin, $end);
dd($month);
}