本文整理汇总了PHP中app\Customer::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::findOrFail方法的具体用法?PHP Customer::findOrFail怎么用?PHP Customer::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$person = Person::findOrFail($id);
$customer = Customer::findOrFail($person->customer_id);
$person->delete();
return Redirect::action('CustomersController@show', [$customer->slug]);
}
示例2: delAccount
public function delAccount(Request $request)
{
$Account_IDs = json_decode(stripslashes($request->accountIds));
$check = false;
foreach ($Account_IDs as $id) {
$user = User::find($id);
if ($user->username == Auth::user()->username) {
return "Không thể xóa account \"" . $user->username . "\"";
}
$user->deleted = 1;
$check = $user->save();
if ($check) {
$customer = Customer::findOrFail($user->userable_id);
$customer->deleted = 1;
$check = $customer->save();
} else {
break;
}
}
if ($check) {
return "true";
} else {
return "Có lỗi xảy ra. Vui lòng thử lại sau!";
}
}
示例3: ajaxPlans
public function ajaxPlans()
{
$arr = array();
$plans = Plan::where('mr_id', \Auth::user()->id)->approved()->get();
$leave = LeaveRequest::where('mr_id', \Auth::user()->id)->approved()->get();
$i = 0;
foreach ($plans as $singlePlan) {
$arr[$i]['start'] = $singlePlan['date'];
$arr[$i]['title'] = $singlePlan->comment ? $singlePlan->comment : '';
$arr[$i]['color'] = 'black';
$i++;
foreach (json_decode($singlePlan['doctors']) as $singleDoctorId) {
$color = $this->isDoctorVisited($singleDoctorId, $singlePlan['date']) == true ? 'green' : 'red';
$url = $this->isDoctorVisited($singleDoctorId, $singlePlan['date']) != true ? \URL::route('addReport', $singleDoctorId) : NULL;
$arr[$i]['url'] = $url;
$arr[$i]['title'] = Customer::findOrFail($singleDoctorId)->name;
$arr[$i]['start'] = $singlePlan['date'];
$arr[$i]['color'] = $color;
$i++;
}
}
foreach ($leave as $singleLeave) {
$arr[$i]['title'] = 'Holiday';
$arr[$i]['start'] = $singleLeave['leave_start'];
$arr[$i]['end'] = date('Y-m-d', strtotime($singleLeave['leave_end'] . "+1 days"));
$arr[$i]['color'] = '#9b59b6';
$arr[$i]['allDay'] = true;
$i++;
}
return json_encode($arr);
}
示例4: create
/**
* Show the form for creating a new resource.
*
* @param int $customer_id
* @return \Illuminate\Http\Response
*/
public function create($customer_id)
{
$customer = Customer::findOrFail($customer_id);
$order = new Order();
$order->customer_id = $customer->id;
$order->save();
return redirect()->route('order.show', $order->id);
}
示例5: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create($id)
{
$customer = Customer::findOrFail($id);
if ($customer->id != Auth::user()->id) {
return redirect()->route("admin", Auth::user()->id);
}
return view('admin.create', compact('customer'));
}
示例6: 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)
{
$customer = Customer::findOrFail($id);
$customer->update($request->all());
if (session('pp_new_order', false)) {
return redirect()->to('/order/create/' . $customer->id);
}
return redirect()->route('customer.index');
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
if (Auth::user()->admin == 1) {
$customer = Customer::findOrFail($id);
} else {
$customer = Customer::where('group', Auth::user()->group)->where('id', $id)->firstOrFail();
}
return view('customer.show', ['customer' => $customer]);
}
示例8: delete
public function delete(Request $request)
{
$customer = Customer::findOrFail($request->id);
$customer->delete_stat = 1;
$customer->save();
$customerid = $customer->id;
$employeeid = Auth::user()->id;
$log = ActivityLog::create(['employee_id' => $employeeid, 'activity' => 'Delete Suppliers', 'table_affected' => 'customer=', 'primary_key' => $customerid, 'column_affected' => 'delete_stat']);
return redirect()->route('erp_system.customer.index')->withSuccess('Customer deleted.');
}
示例9: create
public function create()
{
$id = \Request::get('id');
try {
$customer = Customer::findOrFail($id);
return view('transaction.create', compact('customer'));
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return redirect('transaction')->with('message', 'Data dengan kode transaksi tersebut tidak ditemukan!');
}
}
示例10: saveCustomer
public function saveCustomer($customerId)
{
$customer = Customer::findOrFail($customerId);
$input = \Input::all();
$customer->fill($input);
if (!$customer->save()) {
return \Redirect::route('customers.edit', $customerId)->withErrors($customer->getErrors())->withInput();
}
return \Redirect::to('/customers');
}
示例11: update
/**
* Update the specified resource in storage.
*
* @param UpdateCustomerRequest|Request $request
* @param Customer $customer
* @return \Illuminate\Http\Response
*/
public function update(UpdateCustomerRequest $request, $id)
{
$customer = Customer::findOrFail($id);
$customer->street = $request->get('street');
$customer->city_id = $request->get('city_id');
$customer->phone = $request->get('phone');
$customer->save();
$user = User::findOrFail($customer->user->id);
$user->name = $request->get('name');
$user->surname = $request->get('surname');
$user->email = $request->get('email');
$user->save();
$customer->user()->save($user);
return redirect('/');
}
示例12: sendToCustomer
public function sendToCustomer($customerId)
{
$customer = Customer::findOrFail($customerId);
$message = Input::get('message');
if (trim($message)) {
if ($customer->phone) {
\Sms::send_sms($customer->phone, $message);
}
}
if (!\Sms::error()) {
\Session::flash('success', 'Sms sent!');
} else {
\Session::flash('error', 'Failed!');
}
return \Redirect::back();
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$cart = $request->session()->get('cart');
$customer = Customer::findOrFail(auth()->user()->userable_id);
$order_price = 0;
$order = Order::create(['ordered_by' => $customer->id, 'state_id' => OrderState::where('name', 'pending')->first()->id]);
foreach ($cart as $product_id => $quantity) {
$order->products()->attach($product_id, ['quantity' => $quantity]);
$product = Product::findOrFail($product_id);
$product->stock -= $quantity;
$product->save();
$order_price += $quantity * $product->price;
}
$order->price = $order_price;
$order->shipping = rand(100, 10000) / 100;
$order->save();
$request->session()->forget('cart');
event(new OrderWasPurchased($order));
return redirect('customer/purchase/success');
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(CustomerRequest $request, $id)
{
$customer = Customer::findOrFail($id);
$customer->update($request->all());
return redirect('customer')->with('message', 'Data berhasil dirubah!');
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(CustomerRequest $request, $id)
{
$customer = Customer::findOrFail($id);
$customer->update($request->all());
return redirect('customers');
}