/** * Handle the event. * * @param MerchantsWasCreated $event * @return void */ public function handle(MerchantsWasCreated $event) { $event->request->merge(array('merchant_id' => $event->merchant_id, 'outlet_no' => md5($event->merchant_id))); $restaurant = $this->restaurant->create($event->request->all()); $this->outlet->create($event->request->all()); foreach ($event->request->cuisine_id as $key => $value) { $this->restaurantCuisineInterface->create(['restaurant_id' => $restaurant->id, 'cuisine_id' => $value]); } return true; }
/** * Display merchant profile page. * * @return View */ public function index() { $merchant_id = Auth::user()->id; $restaurant = $this->restaurant->getByAttributes(['merchant_id' => $merchant_id], false); $selected_cuisines = $this->restaurantCuisine->getByAttributesWithRelations(['restaurant_id' => $restaurant->id], ['cuisine'])->toArray(); $cuisines_id = array_map(function ($structure) { return $structure['cuisine']['id']; }, $selected_cuisines); $data = array('merchant' => $this->merchant->getById($merchant_id), 'restaurant' => $restaurant, 'snapshot' => $this->snapshot->getByAttributes(['merchant_id' => $merchant_id]), 'outlet' => $this->outlet->getByAttributes(['merchant_id' => $merchant_id, 'main' => 1], false), 'outlets' => $this->outlet->getByAttributes(['merchant_id' => $merchant_id, 'main' => 0]), 'restaurant_cuisine' => $selected_cuisines, 'cuisines' => $this->cuisine->getAll(), 'cuisines_id' => $cuisines_id); return view('merchant.profile', $data); }
/** * Upload photo for merchant cover photo. * * @param integer $id * @param Outlet $request * @param ImageUploader $imageUploader * @return Redirect */ public function uploadCoverPhoto(Request $request, ImageUploader $imageUploader) { /* $fileArray = array('file' => $file); $user_id = Auth::user()->id;*/ $file = $request->file('file'); $user_id = Auth::user()->id; if (!in_array($file->getClientOriginalExtension(), array('gif', 'png', 'jpg', 'jpeg'))) { return Response::json(array('code' => 404, 'message' => 'Invalid format'), 404); } $this->restaurant->updateByAttributes(['merchant_id' => $user_id], ['res_logo_background' => 'uploads/' . $user_id]); return $imageUploader->upload($file, $user_id, 500, 500, 'uploads/', '/cover_photo.jpg'); }
/** * Display campaign page. * * @return View */ public function index() { $data = array('restaurant' => $this->restaurant->getByAttributes(['merchant_id' => Auth::user()->id], false), 'campaigns' => $this->campaign->getAllByAttributes(['merchant_id' => Auth::user()->id], 'created_at', 'DESC')); return view('notifications.index', $data); }
/** * Display edit campaign page. * * @param integer $id * @return View */ public function edit($id) { $data['restaurant'] = $this->restaurant->getByAttributes(['merchant_id' => Auth::user()->id], false); $data['campaign'] = $this->campaign->getById($id); return view('campaign.edit', $data); }