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')); }
/** * 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')); }
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!"; } } }
/** * 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)); }
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 />"; } }
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 />"; } }
public function show($id) { $customer = Customer::find($id); echo 'Hello my name is ' . $customer->name . "<br />"; // added after creating relationship $orders = $customer->orders; foreach ($orders as $order) { echo $order->name . "<br />"; } }
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/>"; } }
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); }
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); }
/** * 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')); }
/** * 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]); }
/** * 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]); }
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(); }
/** * 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; } }); }
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; } }
function pay(Request $request) { $token = $request['token']; $customer_id = $request['customer_id']; $total_price = $request['total'] * 100; $customer = Customer::find($customer_id); if ($customer->charge($total_price, ['source' => $token, 'receipt_email' => $customer->email])) { $message = ['status' => 'OK', 'message' => 'Payment OK']; return $message; } else { $message = ['status' => 'Error', 'message' => 'Error submitting payment']; return $message; } }
public function chargeCreditCard($customer_id, $amount, $options) { $charge = false; $customer = Customer::find($customer_id); if ($customer) { $charge = $customer->charge($amount, $options); } return $charge; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($idcus) { $customer = Customer::find($idcus)->delete(); return Redirect::to('customer'); }
public function destroy($id) { Customer::find($id)->delete(); $customers = Customer::orderBy('customer')->paginate(env('CUSTOMER_PAGINATION_MAX')); return view('customers.index')->with('customers', $customers); }
public function savecde() { $id = Auth::user()->id; if (User::find($id)->customer) { $customer_id = User::find($id)->customer->id; $num_cde = History::orderBy('cde_id', 'desc')->first()->cde_id + 1; foreach (Session::get('cde') as $pdts) { foreach ($pdts as $pdt) { $product = Product::find($pdt['id']); $h = new History(); $h->product_id = $pdt['id']; $h->customer_id = $customer_id; $h->cde_id = $num_cde; $h->price = $product->price; $h->quantity = $pdt['quantity']; $h->command_at = Carbon::now(); $h->status = 'finalized'; $h->save(); $product->quantity -= $pdt['quantity']; $product->save(); } } $customer = Customer::find($customer_id); $customer->number_command += 1; $customer->save(); Session::forget('cde'); return redirect('/')->with(['message' => 'Votre commande a bien été validée sous le N° ' . $num_cde, 'alert' => 'success']); } else { return redirect('/registerCustomer'); } }
public function customers(Request $request, $term = null) { // access only super admin if ($this->admin->role_id != 1) { return redirect()->back(); } if ($term == 'testimonials') { return $this->testimonials($request); } if ($term == 'messages') { return $this->messages($request); } if ($request->action == 'create') { return view('admin.pages.customer.create'); } if ($request->action == 'edit' && isset($request->id)) { if (Gate::denies('customer-edit', $request->id)) { return redirect()->back(); } $customer = \App\Customer::find($request->id); return view('admin.pages.customer.edit', compact('customer')); } $request = json_encode($request->all()); $request = json_decode($request, true); $api_url = route('api.customer.index', $request); return view('admin.pages.customer.listing', compact('api_url')); }
/** * Set Customer's block_status to 0. (i.e. unblocked). * * @param Request $request */ public function unblockCustomer(Request $request) { $customer = Customer::find($request->cus_id); $customer->block_status = "0"; $customer->save(); }
/** * 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->validate($request, ['customer_name' => 'required|max:255', 'group_list_selected' => 'required']); Customer::where('id', $id)->update(['name' => $request->customer_name]); $customer = Customer::find($id); // Clear out the old group associations for this customer $customer->groups()->detach(); // Add the new group - customer association foreach ($request->group_list_selected as $g_selected) { $customer->groups()->attach($g_selected); } return redirect('/customers'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Customer::find($id)->delete(); return redirect('customers'); }
public function getView($id) { $transactions = Transaction::where('order_id', '=', $id); return view('a.orderview', compact('transactions'))->with('customers', Customer::find($id))->with('orders', Order::find($id))->with('payments', PaymentProof::where('order_id', '=', $id)->get()); //$customers = Customer::find($id); //return view('a.orderview',compact('customers')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $customer = Customer::find($id); return view('admin.customer.edit', ['customer' => $customer]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return Customer::find($id); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $customer = Customer::find($id); $customer->delete(); // return redirect()->back(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'Customer has been deleted'), 'id' => $id)); }
private function push_to_xero($id) { // Get data for sending customer details $customer = Customer::find($id); $contacts = $customer->customer_contacts; $contactsXML = '<ContactPersons>'; foreach ($contacts as $contact) { $contactsXML .= '<ContactPerson> <FirstName>' . $contact->first_name . '</FirstName> <LastName>' . $contact->last_name . '</LastName> <EmailAddress>' . $contact->email . '</EmailAddress> </ContactPerson>'; } $contactsXML .= '</ContactPersons>'; if (count($contacts) > 0) { $first_name = $contacts[0]->first_name; $last_name = $contacts[0]->last_name; $email = $contacts[0]->email; } else { $first_name = ''; $last_name = ''; $email = ''; } define('BASE_PATH', $_SERVER['DOCUMENT_ROOT']); define("XRO_APP_TYPE", "Private"); define("OAUTH_CALLBACK", 'http://printflow.local:8000/'); /* For Demo-Company define ( "OAUTH_CALLBACK", 'http://printflow.local:8000/' ); $useragent = "Demo-Printflow"; $signatures = array ( 'consumer_key' => 'NLOXKOEM8QUFCW9XCKWH7DQMARCWUW', 'shared_secret' => 'YEACQD0QQ2R5X1YCBFV6LZKMMLIYRT', // API versions 'core_version' => '2.0', 'payroll_version' => '1.0' ); */ $useragent = env('USER_AGENT'); $signatures = array('consumer_key' => env('XERO_KEY'), 'shared_secret' => env('XERO_SECRET'), 'core_version' => '2.0', 'payroll_version' => '1.0'); if (XRO_APP_TYPE == "Private" || XRO_APP_TYPE == "Partner") { $signatures['rsa_private_key'] = BASE_PATH . '/certs/privatekey.pem'; $signatures['rsa_public_key'] = BASE_PATH . '/certs/publickey.cer'; } $XeroOAuth = new \XeroOAuth(array_merge(array('application_type' => XRO_APP_TYPE, 'oauth_callback' => OAUTH_CALLBACK, 'user_agent' => $useragent), $signatures)); $initialCheck = $XeroOAuth->diagnostics(); $checkErrors = count($initialCheck); if ($checkErrors > 0) { // you could handle any config errors here, or keep on truckin if you like to live dangerously foreach ($initialCheck as $check) { echo 'Error: ' . $check . PHP_EOL; } } else { $session = $this->persistSession(array('oauth_token' => $XeroOAuth->config['consumer_key'], 'oauth_token_secret' => $XeroOAuth->config['shared_secret'], 'oauth_session_handle' => '')); $oauthSession = $this->retrieveSession(); if (isset($oauthSession['oauth_token'])) { $XeroOAuth->config['access_token'] = $oauthSession['oauth_token']; $XeroOAuth->config['access_token_secret'] = $oauthSession['oauth_token_secret']; if (isset($_REQUEST)) { if (!isset($_REQUEST['where'])) { $_REQUEST['where'] = ""; } } if (isset($_REQUEST['wipe'])) { session_destroy(); header("Location: {$here}"); // already got some credentials stored? } elseif (isset($_REQUEST['refresh'])) { $response = $XeroOAuth->refreshToken($oauthSession['oauth_token'], $oauthSession['oauth_session_handle']); if ($XeroOAuth->response['code'] == 200) { $session = $this->persistSession($response); $oauthSession = $this->retrieveSession(); } else { $this->outputError($XeroOAuth); if ($XeroOAuth->response['helper'] == "TokenExpired") { $XeroOAuth->refreshToken($oauthSession['oauth_token'], $oauthSession['session_handle']); } } } elseif (isset($oauthSession['oauth_token']) && isset($_REQUEST)) { $XeroOAuth->config['access_token'] = $oauthSession['oauth_token']; $XeroOAuth->config['access_token_secret'] = $oauthSession['oauth_token_secret']; $XeroOAuth->config['session_handle'] = $oauthSession['oauth_session_handle']; $xml = '<Contacts> <Contact> <Name>' . $customer->customer_name . '</Name> <FirstName>' . $first_name . '</FirstName> <LastName>' . $last_name . '</LastName> <EmailAddress>' . $email . '</EmailAddress> <Addresses> <Address> <AddressType>POBOX</AddressType> <AttentionTo>' . $customer->postal_attention . '</AttentionTo> <AddressLine1>' . $customer->customer_name . '</AddressLine1> <AddressLine2>' . $customer->postal_street . '</AddressLine2> <AddressLine3> </AddressLine3> <AddressLine4> </AddressLine4> <City>' . $customer->postal_city . '</City> <Region>' . $customer->postal_state . '</Region> <PostalCode>' . $customer->postal_postcode . '</PostalCode> <Country>' . $customer->postal_country . '</Country> </Address> <Address> <AddressType>STREET</AddressType> <AttentionTo>' . $customer->postal_attention . '</AttentionTo> <AddressLine1>' . $customer->customer_name . '</AddressLine1> <AddressLine2>' . $customer->postal_street . '</AddressLine2> <AddressLine3> </AddressLine3> <AddressLine4> </AddressLine4> <City>' . $customer->postal_city . '</City> <Region>' . $customer->postal_state . '</Region> <PostalCode>' . $customer->postal_postcode . '</PostalCode> <Country>' . $customer->postal_country . '</Country> </Address> </Addresses> <Phones> <Phone> <PhoneType>DEFAULT</PhoneType> <PhoneNumber>' . $customer->tel_number . '</PhoneNumber> <PhoneAreaCode>' . $customer->tel_area . '</PhoneAreaCode> <PhoneCountryCode>' . $customer->tel_country . '</PhoneCountryCode> </Phone> <Phone> <PhoneType>MOBILE</PhoneType> <PhoneNumber>' . $customer->mobile_number . '</PhoneNumber> <PhoneAreaCode>' . $customer->mobile_area . '</PhoneAreaCode> <PhoneCountryCode>' . $customer->mobile_country . '</PhoneCountryCode> </Phone> </Phones> <Website>' . $customer->web_address . '</Website> <IsCustomer>true</IsCustomer> ' . $contactsXML . ' </Contact> </Contacts>'; $response = $XeroOAuth->request('POST', $XeroOAuth->url('Contacts', 'core'), array(), $xml); if ($XeroOAuth->response['code'] == 200) { return 'OK'; } else { $this->outputError($XeroOAuth); return 'ERROR'; } } } } return 'ERROR'; }