本文整理汇总了PHP中Customer::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::find方法的具体用法?PHP Customer::find怎么用?PHP Customer::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUser
public function actionUser()
{
//Customer::deleteAll();
if (isset($_POST['searchV'])) {
$searchq = $_POST['searchV'];
$query = CustomerSocialLogin::findBySql('select * from customer')->all();
/*for($x=1;$x<6;$x++)
{
$customer = Customer::get($x);
var_dump($customer->customer_user_name);
} */
/* $count=1;
foreach($query as $q)
{
$customer = new Customer();
$customer->primaryKey = $count;
$customer->attributes = ['customer_user_name' => $q->customer_user_name, 'customer_first_name' => $q->customer_first_name,'customer_last_name' => $q->customer_last_name];
$customer->save();
$count++;
} */
//$result = Customer::find()->query(["match" => ["customer_user_name" => $searchq]])->asArray()->all();
$result = Customer::find()->query(["fuzzy_like_this" => ["fields" => ["customer_user_name"], "like_text" => $searchq, "max_query_terms" => 25]])->asArray()->all();
//var_dump($result);
for ($x = 0; $x < count($result); $x++) {
$val = $result[$x];
$res = $val['_source'];
$res = $res['customer_user_name'];
echo '<div>   <a>' . $res . '</a></div>';
}
} else {
echo '<div>   no results for the search</div>';
}
}
示例2: deleteIndex
public function deleteIndex()
{
$id = Input::get('id');
$customer = Customer::find($id);
$customer->delete();
return $id;
}
示例3: getCustomer
public function getCustomer($id)
{
$customer = Customer::find($id);
if ($customer == null) {
return Error::make("No Customer Found");
} else {
return Error::success("Customer found", $customer->toArray());
}
}
示例4: 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 View::make('admin/appointments')->with('appointments', $calendarAppointments);
}
示例5: update
public function update()
{
$inputs = Input::all();
$customer = Customer::find($inputs['pk']);
$customer->{$inputs}['name'] = $inputs['value'];
//tt($customer->save());
if ($customer->save()) {
$data['status'] = 'success';
} else {
$data['status'] = 'danger';
}
return Response::json($data);
}
示例6: delete
/**
*
* @param type $_id
* @return \Illuminate\Http\Response Description
*/
public function delete($_id)
{
$customer = Customer::find($_id);
$response = array('status' => false, '_id' => $_id);
$contracts = $customer->contracts();
if ($customer->delete()) {
foreach ($contracts as $contract) {
$contract->delete();
}
$response['status'] = true;
}
$headers = array('Content-type' => 'application/json');
return \Illuminate\Http\Response::create($response, 200, $headers);
}
示例7: update
public function update($id)
{
// Validation
$input = Input::all();
try {
$validate_data = $this->_validator->validate($input);
} catch (ValidationException $e) {
return Redirect::back()->withInput()->withErrors($e->get_errors());
}
$customer = Customer::find($id);
if (!$customer->update($input)) {
return Redirect::back()->with('error', 'Error while trying to update Customer')->withInput();
}
return Redirect::route('show_customer_path', array($customer['id']))->with('success', 'Customer updated.');
}
示例8: profile
/**
* Display the customer's profile page after successful login.
*/
public function profile(Customer $customer = NULL)
{
if (is_null($customer)) {
if (Auth::check()) {
//echo Auth::user()->email;
$customer = Customer::find(Auth::id());
$orders = Order::where('customer_id', '=', Auth::id())->get();
$this->layout->content = View::make('customers.profile', compact('customer', 'orders'));
} else {
return Redirect::to('login');
}
} else {
$orders = Order::where('customer_id', '=', $customer->id)->get();
$this->layout->content = View::make('customers.profile', compact('customer', 'orders'));
}
}
示例9: indexAction
public function indexAction()
{
if (!$this->request->isPost()) {
Tag::setDefault('email', ' ');
Tag::setDefault('password', '');
} else {
$name = trim($this->request->getPost('name', array('string', 'striptags')));
$password = trim($this->request->getPost('password'));
$password = sha1($password);
$detail = Customer::find("name = " . $name);
if ($password == sha1($detail->num)) {
return $this->forward("search/jump");
} else {
$this->flash->error("错误");
}
}
}
示例10: login
public function login()
{
if ($this->authData()) {
$name = Input::get('name');
$id = Customer::where('name', $name)->pluck('id');
$user = Customer::find($id);
Auth::login($user);
if (Auth::check()) {
Session::put('isAdmin', TRUE);
return Redirect::to('admin/index.html');
} else {
$result = ['err' => 1001, 'msg' => '登录失败'];
}
} else {
$result = ['err' => 1001, 'msg' => '验证不通过'];
}
return Response::json($result);
}
示例11: indexAction
public function indexAction()
{
$numberPage = 1;
$searchParams = array();
if ($this->request->isPost()) {
//$query = Criteria::fromInput($this->di, "Customer", $_POST);
$keyword = trim($this->request->getPost("keyword", "striptags"));
if (isset($keyword) && $keyword != '') {
if (strlen($keyword) == 18) {
$searchParams = array("number = '" . $keyword . "'");
} else {
$searchParams = array("name = '" . $keyword . "'");
}
//$this->persistent->searchParams = $query->getParams();
} else {
$this->flash->notice("请重新输入搜索条件");
}
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = array();
if ($searchParams) {
$parameters = $searchParams;
}
$customer = Customer::find($parameters);
if (count($customer) == 0) {
$this->flash->notice("没有找到对应的合同");
}
$paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $customer, "limit" => 10, "page" => $numberPage));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
$this->view->setVar("customer", $customer);
}
示例12: delete
/**
* Remove the specified resource from storage.
* DELETE /adminbuildings/{id}
*
* @param int $id
* @return Response
*/
public function delete($id)
{
$customer = Customer::find($id);
$public_path = public_path() . $this->public_path;
$image_fields = $this->image_fields;
for ($i = 0; $i < count($image_fields); $i++) {
if (file_exists($public_path . $customer->{$image_fields}[$i])) {
File::delete($public_path . $customer->{$image_fields}[$i]);
}
}
Customer::destroy($id);
return Redirect::back();
}
示例13: function
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
if (Session::token() !== Input::get('_token')) {
throw new Illuminate\Session\TokenMismatchException();
}
});
/*
|--------------------------------------------------------------------------
| Admin Filter
|--------------------------------------------------------------------------
|
| Check to determine if currently logged in user is an Administrator,
| based on the 'admin_ind' database flag.
|
*/
Route::filter('admin', function () {
if (Auth::guest()) {
return Redirect::route('login')->with('message', 'You must log in to access admin area of site.');
} else {
$customer = Customer::find(Auth::id());
Log::debug('Admin filter - customer: ' . print_r($customer, TRUE));
if (!$customer->admin_ind) {
return Redirect::route('home')->with('message', '<strong>You are not authorized to access admin area of site.</strong>');
}
}
});
示例14: array
<li><!-- HOME -->
<a href="{{URL::Route('home')}}">
HOME
</a>
</li>
@if(Auth::check())
<?php
$data = array("first_name" => "User");
$id = Auth::user()->id;
switch (Auth::user()->type) {
case 'driver':
$data = Driver::find($id)->toArray();
break;
case 'customer':
$data = Customer::find($id)->toArray();
break;
case 'business':
$data = Business::find($id)->toArray();
break;
}
?>
<li><!-- HOME -->
<a href="{{URL::Route('edit')}}">
Edit
</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" href="#">
Hi! {{$data["first_name"]}}
示例15: createQuotation
/**
* Generates quotation requests
*
* @param int $customerId
* @return Response
* @author Gat
**/
public function createQuotation($customerId)
{
$directAward = Input::get('award') ? true : false;
$customer = Customer::find($customerId);
$secretary = Auth::user();
// Check if customer has a representative
if ($customer->representatives->isEmpty()) {
return Redirect::route('customers.edit', ['id' => $customerId])->with('message', 'Add a customer representative first')->with('alert-class', 'danger');
}
// Get Initials
$initialsPatern = '~\\b(\\w)|.~';
$customerInitials = preg_replace($initialsPatern, '$1', $customer->name);
$secretaryInitials = preg_replace($initialsPatern, '$1', $secretary->full_name);
// TEMPORARY
// RFQ = Customer's Initials - DDMM - Secretary's Initials
$rfq = $customerInitials . '-' . date('dm') . '-' . $secretaryInitials;
// Append number if existing
$quotations = Quotation::where('rfq_id', 'LIKE', "{$rfq}%");
if ($quotations->count()) {
$rfq = $rfq . '-' . $quotations->count();
}
// Create quotation
$quotation = Quotation::create(['customer_id' => $customer->id, 'secretary_id' => $secretary->id, 'rfq_id' => $rfq, 'direct_award' => $directAward]);
return Redirect::route('quotations.request', ['rfq' => Str::slug($rfq)]);
}