Esempio n. 1
0
 /**
  * @param ShopRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function storeShop(ShopRequest $request)
 {
     $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new Attachment(), 'shops');
     $shop = new Shops();
     $shop->capacity = $request->get('capacity');
     $shop->city_id = $request->get('city');
     $shop->paid_at = Carbon::now()->addMonth();
     $shopProfile = new ShopProfile();
     $shopProfile->fill($request->except('attachment'));
     $shopProfile->save();
     $shop->profile()->associate($shopProfile);
     if ($attachment) {
         $shop->attachment()->associate($attachment);
     }
     $page = $request->page;
     $shop->user_id = $request->user_id;
     $shop->save();
     return redirect($page);
 }
Esempio n. 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param ShopRequest $request
  * @param Shops $shops
  * @return Response
  * @internal param int $id
  */
 public function update(ShopRequest $request, Shops $shops)
 {
     if (Auth::check()) {
         if ($shops->user_id != Auth::user()->id) {
             return redirect('/');
         }
     }
     ShopProfile::find($shops->profile_id)->update($request->except('attachment')['profile']);
     if ($request->file('attachment')) {
         $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new Attachment(), 'shops');
         $shops->fill($request->only('attachment'));
         $shops->attachment()->associate($attachment);
     }
     $shops->city_id = $request->get('city');
     $shops->update();
     return redirect()->route('shops.show', $shops->id);
 }