本文整理汇总了PHP中app\models\Customer::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::find方法的具体用法?PHP Customer::find怎么用?PHP Customer::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Customer
的用法示例。
在下文中一共展示了Customer::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 "操作成功!";
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$this->validation_rules($request);
$customerUpdate = $request->input();
$customer = Customer::find($id);
$customer->update($customerUpdate);
Session::flash('flash_message', 'Data pelanggan berhasil diupdate!');
return redirect('admin/customer');
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$customer = Customer::find($id);
if (!$customer) {
return response()->json('Le client n\'existe pas.', 404);
}
$customer->delete();
return 'Le client a bien été supprimé.';
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$customer = null;
if (!empty($id)) {
$customer = Customer::find($id);
$customer_details = DB::table('customer_details')->where('customer_uuid', $customer->uuid)->get();
}
// print_r($customer);
return view('customer.edit', ['theme' => 'default', 'customer' => $customer, 'customer_details' => $customer_details]);
}
示例5: testInvite
public function testInvite()
{
$c = Customer::find(3);
$counter = new CustomerInvitationCounter(Customer::find(1));
$before = $counter->getMonthlyCount();
// $this->assertEquals(0, $before);
event(new Register($c));
$after = $counter->getMonthlyCount();
$this->assertEquals($before + 1, $after);
}
示例6: actionCategory
public function actionCategory($url = null)
{
$query = Project::find();
$addition = Project::find()->select('id')->orderBy('id ASC')->limit(3)->asArray()->all();
if (!is_null($url)) {
$query->innerJoinWith('category', 'category_id = category_id')->where(['url' => $url]);
}
$dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 9]]);
$projectModel = Project::find()->joinWith('category', 'category.category_id = project.category_id')->orderBy('id ASC')->limit(3)->all();
return $this->render('category', ['dataProvider' => $dataProvider, 'categoryModel' => Category::find()->all(), 'customerModel' => Customer::find()->all(), 'projectModel' => $projectModel]);
}
示例7: update
public function update(Request $request, $id)
{
$this->validate($request, $this->rules);
$data = $request->all();
/* @var Receivable $receivable */
$receivable = Receivable::find($id);
$receivable->update($data);
$customer = Customer::find($data['customer']['id']);
$receivable->customer()->associate($customer);
$receivable->save();
return (new ApiParcel())->addMessage('general', 'Conta a pagar alterado com sucesso!');
}
示例8: getIndex
public function getIndex()
{
if (Auth::customer()->check()) {
$id = Auth::customer()->user()->id;
$table = new Customer();
if (!empty($id)) {
$table = Customer::find($id);
}
return viewc('client.' . self::NAMEC . '.index', compact('table'));
}
return redirect('login')->with('messageError', 'Inicie sesion');
}
示例9: getAppointments
public function getAppointments()
{
$appointments = Appointment::all();
$calendarAppointments = array();
foreach ($appointments as $a) {
$customer = Customer::find($a['customer_id']);
$customer = $customer->first_name . ' ' . $customer->last_name;
$event = array('title' => 'Appointment with ' . $customer, 'start' => $a['appointment_datetime']);
array_push($calendarAppointments, $event);
}
return response()->json($calendarAppointments);
}
示例10: index
public function index()
{
if (!$this->hasPermission($this->menuPermissionName)) {
return view($this->viewPermissiondeniedName);
}
$provinces = Province::whereHas('branchs', function ($q) {
$q->where('isheadquarter', true);
})->orderBy('name', 'asc')->get(['id', 'name']);
$provinceselectlist = array();
array_push($provinceselectlist, ':เลือกจังหวัด');
foreach ($provinces as $item) {
array_push($provinceselectlist, $item->id . ':' . $item->name);
}
if (Auth::user()->isadmin) {
$customers = Customer::has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
} else {
$customers = Customer::where('provinceid', Auth::user()->provinceid)->has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
}
$customerselectlist = array();
foreach ($customers as $item) {
array_push($customerselectlist, $item->id . ':' . $item->title . ' ' . $item->firstname . ' ' . $item->lastname);
}
if (Auth::user()->isadmin) {
$cars = Car::has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
} else {
$cars = Car::where('provinceid', Auth::user()->provinceid)->has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
}
$carselectlist = array();
array_push($carselectlist, ':เลือกรถ');
foreach ($cars as $item) {
array_push($carselectlist, $item->id . ':' . $item->chassisno . '/' . $item->engineno);
}
if (Auth::user()->isadmin) {
$carpreemptions = CarPreemption::has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']);
} else {
$carpreemptions = CarPreemption::where('provinceid', Auth::user()->provinceid)->has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']);
}
$carpreemptionselectlist = array();
array_push($carpreemptionselectlist, ':เลือกการจอง');
foreach ($carpreemptions as $item) {
$buyercustomer = Customer::find($item->buyercustomerid);
$buyercustomername = $buyercustomer->title . ' ' . $buyercustomer->firstname . ' ' . $buyercustomer->lastname;
$salesmanemployee = Employee::find($item->salesmanemployeeid);
$salesmanemployeename = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname;
array_push($carpreemptionselectlist, $item->id . ':' . str_pad($item->bookno . '/' . $item->no, strlen($item->bookno . '/' . $item->no) + 15, " ") . str_pad($buyercustomername, strlen($buyercustomername) + 15, " ") . $salesmanemployeename);
}
$defaultProvince = '';
if (Auth::user()->isadmin == false) {
$defaultProvince = Auth::user()->provinceid;
}
return view('redlabel', ['provinceselectlist' => implode(";", $provinceselectlist), 'customerselectlist' => implode(";", $customerselectlist), 'carselectlist' => implode(";", $carselectlist), 'carpreemptionselectlist' => implode(";", $carpreemptionselectlist), 'defaultProvince' => $defaultProvince]);
}
示例11: actionIndex
public function actionIndex()
{
$categoryModel = Category::find()->All();
$projectModel = Project::find()->where(['show_in_index' => '1'])->limit(6)->all();
$customerModel = Customer::find()->All();
$applicationConfig = ApplicationConfig::find()->one();
$newsModel = News::find()->where(['show_in_index' => '1'])->limit(2)->all();
$galleryModel = Gallery::find()->orderBy(new Expression('rand()'))->limit(6)->all();
$visitor = ApplicationConfig::findOne(1);
$visitor->visitors_count = $visitor->visitors_count + 1;
$visitor->save();
return $this->render('index', ['categoryModel' => $categoryModel, 'projectModel' => $projectModel, 'customerModel' => $customerModel, 'applicationConfig' => $applicationConfig, 'newsModel' => $newsModel, 'galleryModel' => $galleryModel]);
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Customer::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Customer::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['customer_id' => $this->customer_id, 'cust_group_id' => $this->cust_group_id, 'salutation' => $this->salutation, 'gender' => $this->gender, 'last_password_gen' => $this->last_password_gen, 'birthday' => $this->birthday, 'flag_newsletter' => $this->flag_newsletter, 'status' => $this->status, 'flag_active' => $this->flag_active, 'date_added' => $this->date_added, 'date_update' => $this->date_update]);
$query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'mobile_phone', $this->mobile_phone])->andFilterWhere(['like', 'ip_add_newsletter', $this->ip_add_newsletter])->andFilterWhere(['like', 'note', $this->note])->andFilterWhere(['like', 'last_visit', $this->last_visit]);
return $dataProvider;
}
示例14: search_supplier
public function search_supplier($params)
{
$query = Customer::find()->where(['customer_type' => 'S']);
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['customer_id' => $this->customer_id, 'customer_poscode' => $this->customer_poscode]);
$query->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'customer_add1', $this->customer_add1])->andFilterWhere(['like', 'customer_add2', $this->customer_add2])->andFilterWhere(['like', 'customer_add3', $this->customer_add3])->andFilterWhere(['like', 'customer_tel', $this->customer_tel])->andFilterWhere(['like', 'customer_fax', $this->customer_fax])->andFilterWhere(['like', 'customer_email', $this->customer_email])->andFilterWhere(['like', 'customer_type', $this->customer_type])->andFilterWhere(['like', 'customer_remark', $this->customer_remark])->andFilterWhere(['like', 'customer_attention', $this->customer_attention])->andFilterWhere(['like', 'customer_active', $this->customer_active])->andFilterWhere(['like', 'customer_GSTno', $this->customer_GSTno]);
return $dataProvider;
}
示例15: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Customer::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'sex' => $this->sex, 'age' => $this->age, 'uid' => Yii::$app->user->id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'tell', $this->tell])->andFilterWhere(['like', 'addr', $this->addr])->andFilterWhere(['like', 'remark', $this->remark]);
return $dataProvider;
}