/** * 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; }
/** * Edit an merchant profile restaurant. * * @param integer $id * @param Outlet $request * @return Redirect */ public function update($id, RestaurantRequest $request) { if ($this->restaurant->updateById($id, $request->all())) { foreach ($request->res_cuisine as $key => $value) { if (!$this->restaurantCuisine->getByAttributes(['restaurant_id' => $id, 'cuisine_id' => $value])) { $this->restaurantCuisine->create(['restaurant_id' => $id, 'cuisine_id' => $value]); } } return redirect('merchant-profile')->with('message', 'Successfully updated.'); } return redirect('merchant-profile')->withInput(); }