public function postAdd(CustomerSampleRequest $request, CustomerRepository $customer)
 {
     $data = $request->all();
     $sample = null;
     if (session('customer.token')) {
         $loggedCustomer = $customer->getByToken();
         $data['customer_id'] = $loggedCustomer->id;
         $sample = $this->sample->add($data);
     }
     if ($sample) {
         $request->session()->put('customer.justaddedsample', true);
         $job = (new NotifyAdminOfNewSample($sample, config('app.locale')))->onQueue('emails');
         $this->dispatch($job);
     }
     $response = ['success' => $sample];
     return $response;
 }
示例#2
0
 /**
  * We create or update the Customer.
  *
  * @param array    $data
  * @param int|null $id
  *
  * @return Customer
  */
 protected function saveCustomer(array $data = [], $id = null)
 {
     // Image Handling
     if (isset($data['image'])) {
         $data['image'] = $this->buildImage(str_slug($data['label']), $data['image']);
     }
     // We create the Customer
     if ($id === null) {
         return $this->customers->create($data);
     }
     return $this->customers->update($data, $id);
 }
 public function customers(CustomerRepository $customers)
 {
     return view('admin.main')->with('customers', $customers->all());
 }
示例#4
0
 /**
  * Home Page.
  *
  * @return \Illuminate\View\View
  */
 public function home()
 {
     $works = $this->works->all();
     $customers = $this->customers->all();
     return view('frontend.pages.home', compact('works', 'customers'));
 }