本文整理汇总了PHP中app\Customer::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::find方法的具体用法?PHP Customer::find怎么用?PHP Customer::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showGroup
public function showGroup()
{
$customer_id = Auth::user()->customer->id;
$group = User::with('unpaidOrders')->where('customer_id', $customer_id)->get();
$spendings = Customer::find($customer_id)->unpaidOrders->sum('total_price');
return view('account.group', compact('group', 'spendings'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($id)
{
$customer = Customer::find($id);
$titles = Title::where('customer_id', Auth::user()->id)->orderBy('created_at', 'desc')->get();
$allUsers = $this->getAllUsers($customer);
return view("titles.index", compact('titles', 'allUsers', 'customer'));
}
示例3: saveCustomer
public function saveCustomer(Request $request)
{
if ($request->customer_id != "") {
$customer = Customer::find($request->customer_id);
$customer->name = $request->name;
$customer->phone = $request->phone;
$customer->address = $request->address;
User::where('userable_id', '=', $request->customer_id)->update(['email' => $request->email, 'banned' => $request->banned]);
$check = $customer->save();
if ($check) {
return "EDIT_SUCCEED";
} else {
return "Có lỗi xảy ra. Vui lòng thử lại sau!";
}
} else {
$customer = new Customer();
$customer->name = $request->name;
$customer->phone = $request->phone;
$customer->address = $request->address;
$check = $customer->save();
if ($check) {
$data = array('msg' => 'ADD_SUCCEED', 'customer_id' => $customer->id);
return $data;
} else {
return "Có lỗi xảy ra. Vui lòng thử lại sau!";
}
}
}
示例4: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$id = $this->route('id');
if ($id == 0) {
return TRUE;
}
return \Auth::user()->owns(\App\Customer::find($id));
}
示例5: orders
public function orders()
{
$orders = Order::all();
foreach ($orders as $order) {
$customer = Customer::find($order->customer_id);
echo "Ordered by: " . $order->customer->name . "<br />";
echo $order->name . "<p />";
}
}
示例6: show
public function show($id)
{
$customer = Customer::find($id);
echo "my name is: " . $customer->name . "<br />";
$orders = $customer->orders;
foreach ($orders as $order) {
echo $order->name . "<br />";
}
}
示例7: show
public function show($id)
{
echo 'hit';
$customer = Customer::find($id);
echo 'Hello my name is ' . $customer->name . '<br/>';
$orders = $customer->orders;
foreach ($orders as $order) {
echo $order->name . "<br/>";
}
}
示例8: getCustomer
public static function getCustomer($session_token)
{
$session = MobileSession::where('session_id', $session_token)->first();
if ($session) {
$customer_id = $session->user_id;
$customer = Customer::find($customer_id);
return $customer;
}
throw new Exception("Invalid Session Token", 1);
}
示例9: update
function update(Request $request, $id)
{
if ($id) {
$allInput = $request->all();
$customer = Customer::find($id);
$customer->update($allInput);
Session::flash('flash_message', 'Customer updated successfully.');
Session::flash('flash_type', 'alert-success');
}
return redirect('order?c=' . $id);
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$message = Session::get('message');
$customer_id = Session::get('customer');
if (isset($customer_id)) {
$customer = Customer::find($customer_id);
}
$q = QuoteRequest::find($id);
$quote_request = $q;
return view('quote_requests.edit', compact('q', 'quote_request', 'message', 'customer_id', 'customer'));
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store($customerId)
{
$customer = \App\Customer::find($customerId);
$amount = \Input::get('amount');
$payment = new \App\CustomerPayment();
$amount = (int) str_replace(['.', ','], ['', ''], $amount);
$amount *= 100;
$payment->amount = $amount;
$customer->payments()->save($payment);
return redirect()->route('customers.show', [$customerId]);
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$user = User::find(1);
$customer = Customer::find(1);
$contact = Contact::find(1);
$prod = Product::find(1);
$iol_prod = Product::find(2);
$briefing_owner = BriefingOwner::find(1);
$briefing_source = BriefingSource::find(1);
factory(App\Briefing::class)->create(['user_id' => $user->id, 'last_updated_user_id' => $user->id, 'customer_id' => $customer->id, 'customer_type_id' => $customer->customer_type_id, 'contact_id' => $contact->id, 'prod_id' => $prod->id, 'iol_prod_id' => $iol_prod->id, 'briefing_owner_id' => $briefing_owner->id, 'briefing_source_id' => $briefing_source->id]);
}
示例13: save
public function save($id, SaveTransactionRequest $request)
{
$transaction = $this->transactionRepository->getById($id);
if ($transaction && Gate::denies('save', $transaction)) {
return $this->json->error('You cannot alter other\'s Transactions ...');
}
if (!$transaction) {
$transaction = new \App\Transaction();
}
$transaction->fill($request->except(['customer_id']));
\App\Customer::find($request->get('customer_id'))->transactions()->save($transaction);
return $this->json->success();
}
示例14: boot
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @return void
*/
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
// role: super admin, manager, super agent, agent
// page: dashboard, properties(villa, villa rental, land), enquiry, customer, blog, page, setting
$gate->define('property-edit', function ($user, $property_id) {
$user = $user->get();
$property = \App\Property::find($property_id);
if ($user->role_id == 3 or $user->role_id == 4) {
return $property->user_id == $user->id;
}
if ($user->role_id == 2) {
return $property->user->branch_id == $user->branch_id;
}
if ($user->role_id == 1) {
return true;
}
});
$gate->define('enquiry-edit', function ($user, $enquiry_id) {
$user = $user->get();
$enquiry = \App\Enquiry::find($enquiry_id);
if ($user->role_id == 3 or $user->role_id == 4) {
return $enquiry->property->user_id == $user->id;
}
if ($user->role_id == 2) {
return $enquiry->property->user->branch_id == $user->branch_id;
}
if ($user->role_id == 1) {
return true;
}
});
$gate->define('customer-edit', function ($user, $customer_id) {
$user = $user->get();
$customer = \App\Customer::find($customer_id);
// if ($user->role_id == 3 OR $user->role_id == 4) return $customer->user_id == $user->id;
// if ($user->role_id == 2) return $customer->user->branch_id == $user->branch_id;
if ($user->role_id == 1) {
return true;
}
});
$gate->define('user-edit', function ($user, $user_id) {
$user = $user->get();
$account = \App\User::find($user_id);
if ($user->role_id == 2) {
return $account->branch_id == $user->branch_id;
}
if ($user->role_id == 1) {
return true;
}
});
}
示例15: pay
public function pay(Request $request)
{
$token = $request['token'];
$cutomer_id = $request['customer_id'];
$total_price = $request['total'] * 100;
$customer = Customer::find($cutomer_id);
if ($customer->charge($total_price, ['source' => $token, 'receipt_email' => $customer->email])) {
$mess = ['status' => "OK", "message" => "Payment ok"];
return $mess;
} else {
$mess = ['status' => "ERROR", "message" => "Error submitting payment"];
return $mess;
}
}