本文整理汇总了PHP中app\models\Customer::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::where方法的具体用法?PHP Customer::where怎么用?PHP Customer::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Customer
的用法示例。
在下文中一共展示了Customer::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: showDetail
public function showDetail($id)
{
$customer = Customer::where('kode', $id)->firstOrFail();
$reservation = Reservation::where('customer_kode', $id)->orderBy('created_at', 'desc')->firstOrFail();
$transaksi = Reservation::where('customer_kode', $id)->orderBy('id', 'desc')->get();
$sisabayar = DB::table('reservation')->where('customer_kode', '=', $id)->sum('cash');
$tagihan = $reservation->total - $sisabayar;
return view('reservation.detail', compact('customer', 'reservation', 'tagihan', 'transaksi'));
}
示例4: beansLogForUnionId
public function beansLogForUnionId(Request $request)
{
$unionid = $request->input('unionid');
try {
$customer = Customer::where('unionid', $unionid)->firstOrFail();
$beans_log = $customer->beans()->with('rate')->get();
return response()->json(['success' => true, 'data' => ['beans_log' => $beans_log->toArray()]]);
} catch (ModelNotFoundException $e) {
return response()->json(['success' => false, 'error' => 'No such customer.']);
}
}
示例5: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
$customer = Customer::where('name', $data['name'])->first();
if (!$customer) {
$customer = Customer::create($data);
}
// We'll need to link the customer and user in this method
$user = User::create(['email' => $data['email'], 'password' => bcrypt($data['password']), 'sex' => $data['sex'], 'birthdate' => $data['birthdate'], 'customer_id' => $customer->id]);
event(new UserRegistered($user));
return $user;
}
示例6: 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]);
}
示例7: moveUser
public function moveUser()
{
$wechat = new Wechat();
$arr = Customer::where('referrer_id', 25011)->skip(4000)->take(500)->get();
foreach ($arr as $k => $v) {
$result = $wechat->moveUserToGroup($v->openid, 103);
$a = json_decode($result);
// print_r($v->nickname);echo '<br/>';
if ($a->errcode == 0) {
echo $v->nickname . '--移动分组成功' . $a->errcode . '<br.>';
} else {
echo $v->nickname . '--移动分组失败' . $a->errcode . '<br.>';
}
}
}
示例8: getReport
public function getReport(Request $request)
{
$customers = Customer::where('status', 1)->lists('name', 'id');
$employees = Employee::where('status', 1)->lists('name', 'id');
$suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
$cashInHand = DB::table('workspace_ledgers')->where(['account_code' => 11000, 'balance_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_current_financial_year()])->sum('balance');
$sales = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name', 'sales_order.customer_id', 'sales_order.customer_type')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->join('sales_order', 'sales_order.id', '=', 'general_journals.reference_id')->where(['transaction_type' => Config::get('common.transaction_type.sales'), 'account_code' => 31000, 'year' => CommonHelper::get_current_financial_year(), 'general_journals.status' => 1])->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
$salesReturns = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name', 'sales_order.customer_id', 'sales_order.customer_type')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->join('sales_order', 'sales_order.id', '=', 'general_journals.reference_id')->where(['transaction_type' => Config::get('common.transaction_type.sales_return'), 'account_code' => 32000, 'year' => CommonHelper::get_current_financial_year(), 'general_journals.status' => 1])->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
$expenses = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->where('general_journals.account_code', 'like', '2%')->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
$sales = json_decode(json_encode($sales), true);
$salesReturns = json_decode(json_encode($salesReturns), true);
$expenses = json_decode(json_encode($expenses), true);
$ajaxView = view('reports.cashFlow.view', compact('sales', 'salesReturns', 'expenses', 'customers', 'employees', 'suppliers', 'cashInHand'))->render();
return response()->json($ajaxView);
}
示例9: addCustomer
/**
* Function to add a new customer to the database
*
* Returns customer id for appointment creation
*
**/
public static function addCustomer()
{
// We get appointment information then set up our validator
$info = Session::get('appointmentInfo');
$validator = Validator::make(array('first_name' => $info['fname'], 'last_name' => $info['lname'], 'email' => $info['email']), array('first_name' => 'exists:customers,first_name', 'last_name' => 'exists:customers,last_name', 'email' => 'exists:customers,email'));
// If the validator fails, that means the user does not exist
// If any of those three variables don't exist, we create a new user
// This is so that families can use the same e-mail to book, but
// We stil create a new user for them in the database.
if ($validator->fails()) {
// Registering the new user
return Customer::create(array('first_name' => $info['fname'], 'last_name' => $info['lname'], 'contact_number' => $info['number'], 'email' => $info['email'], 'wants_updates' => Session::get('updates')))->id;
} else {
return Customer::where('email', $info['email'])->pluck('id');
}
}
示例10: index
public function index(Request $request){
$search = $request->input('search');
if($search){
$customers = Customer::where('type', '=', 'customer')
->where('lastname', 'LIKE', '%'.$search.'%')
->orWhere('firstname','LIKE','%'.$search.'%')
->get();
}else{
$customers = Customer::where('type', '=', 'customer')->get();
}
$data = [
'customers' => $customers,
'subnav' => $this->default_sub_nav
];
return view('customers.index', $data);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
try {
$user = \Helper::getSessionCachedUser();
$customer = Customer::where('openid', $user['openid'])->firstOrFail();
return $next($request);
} catch (UserNotSubscribedException $e) {
return redirect(AppConstant::ATTENTION_URL);
} catch (UserNotCachedException $e) {
return redirect(AppConstant::ATTENTION_URL);
} catch (ModelNotFoundException $e) {
/** @var array $user */
Customer::create(['openid' => $user['openid'], 'nickname' => $user['nickname'], 'unionid' => isset($user['unionid']) ? $user['unionid'] : null, 'head_image_url' => $user['headimgurl'], 'type_id' => 1]);
return $next($request);
}
}
示例12: persist
public function persist()
{
$filename = $this->moveToLocalStorage($this->file('doctor-information'));
\Excel::load(storage_path('app/doctor-information/' . $filename), function (LaravelExcelReader $reader) {
$result = $reader->get();
foreach ($result as $row) {
$param = ['name' => $row['姓名'], 'type' => substr(trim($row['等级']), 0, 1), 'level' => 5, 'hospital' => $row['所属医院'], 'hospital_level' => $row['医院级别'], 'department' => $row['科室'], 'phone' => strval(intval($row['注册电话'])), 'referred_name' => $row['推荐代表'], 'referred_phone' => strval(intval($row['代表电话'])), 'region' => $row['区域9大区'], 'region_level' => $row['销售大区级别'], 'responsible' => $row['销售地区级别']];
if ($customer = Customer::where('phone', strval(intval($row['注册电话'])))->first()) {
$param['customer_id'] = $customer->id;
}
if ($customer_info = CustomerInformation::where('phone', strval(intval($row['注册电话'])))->first()) {
$customer_info->update($param);
return;
}
CustomerInformation::create($param);
}
});
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
try {
$user = \Helper::getSessionCachedUser();
$customer = Customer::where('openid', $user['openid'])->firstOrFail();
if (!$customer->is_registered) {
\Session::put('register_next_url', $request->fullUrl());
return redirect('/register/create');
}
/*if>*/
if ($this->userDatabaseExpired($customer)) {
$this->refreshUserDatabase($user, $customer);
}
/*if>*/
return $next($request);
} catch (UserNotSubscribedException $e) {
return redirect(AppConstant::ATTENTION_URL);
} catch (UserNotCachedException $e) {
return redirect(AppConstant::ATTENTION_URL);
} catch (ModelNotFoundException $e) {
return redirect(AppConstant::ATTENTION_URL);
}
/*catch>*/
}
示例14: getDoctorCount
protected static function getDoctorCount()
{
return \Cache::remember('enterprise_doctor_count', 60, function () {
return Customer::where('type_id', 4)->count();
});
}
示例15: store
public function store(Request $request)
{
$customerInformation = CustomerInformation::create(['name' => $request->input('name'), 'hospital' => $request->input('hospital'), 'province' => $request->input('province'), 'city' => $request->input('city'), 'district' => $request->input('district'), 'department' => $request->input('department'), 'remark' => $request->input('remark'), 'type' => $request->input('type'), 'referred_name' => $request->input('referred_name'), 'referred_phone' => $request->input('referred_phone'), 'region' => $request->input('region'), 'region_level' => $request->input('region_level'), 'responsible' => $request->input('responsible'), 'hospital_level' => $request->input('hospital_level'), 'phone' => $request->input('phone')]);
$inputPhone = $request->input('phone');
if ($inputPhone) {
$customer = Customer::where('phone', $inputPhone)->first();
if ($customer) {
$customerInformation->update(['customer_id' => $customer->id]);
} else {
$customerInformation->update(['customer_id' => null]);
}
}
if ($request->has('beans_total') && $customer) {
$customer->update(['beans_total' => $request->input('beans_total')]);
}
if ($request->has('type_id') && $customer) {
$customer->update(['type_id' => $request->input('type_id')]);
}
if ($customer) {
return response()->json(['success' => true, 'data' => ['customer' => $customer->with('information')]]);
} else {
return response()->json(['success' => true, 'data' => ['customer' => null]]);
}
}