예제 #1
0
 /**
  * @param Request $request
  * @Post("/gallery/upload")
  * @Patch("/gallery/upload")
  */
 public function upload(Request $request)
 {
     if (!Session::has('gallery_hash')) {
         Session::put('gallery_hash', md5(time()));
     }
     return Response::json(['attachment' => ImageUploadFacade::attachmentUpload($request->file('upl'), new GalleryAttachment(), 'gallery', true)]);
 }
예제 #2
0
 /**
  * Upload profile image
  */
 public function uploadImage($request, $model)
 {
     if (\Request::file('upl')) {
         $image = ImageUploadFacade::attachmentUpload($request->file('upl'), new ProfileAttachment(), 'profile');
         $this->updateProfile(['attachment_id' => $image->id], $model);
         return $image;
     }
 }
예제 #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param Question $questions
  * @param CategoryRequest $request
  * @return Response
  */
 public function update(Question $questions, QuestionRequest $request)
 {
     Session::put('questions_hash', md5(time()));
     $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new QuestionAttachment(), 'questions', true);
     $questions->fill($request->all())->questions_attachment()->associate($attachment);
     $questions->save();
     return redirect()->route('admin.questions.index');
 }
예제 #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(Category $categories, CategoryRequest $request)
 {
     $attachment = ImageUploadFacade::image($request->file('attachment'));
     $categories->fill($request->all());
     if ($attachment) {
         $categories->attachment()->associate($attachment);
     }
     $categories->save();
     return redirect()->route('admin.categories.index');
 }
예제 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param Question $questions
  * @param CategoryRequest $request
  * @return Response
  */
 public function update(Question $questions, QuestionRequest $request)
 {
     $attachment = ImageUploadFacade::image($request->file('attachment'));
     $questions->fill($request->all());
     if ($attachment) {
         $questions->attachment()->associate($attachment);
     }
     $questions->save();
     return redirect()->route('admin.questions.index');
 }
예제 #6
0
 /**
  * @param Request $request
  *
  * @Post("/image/upload");
  */
 public function upload(Request $request)
 {
     $error = '';
     try {
         $url = ImageUploadFacade::upload($request->file('upload'), 'inline');
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $callback = $request->input('CKEditorFuncNum');
     return "<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction(" . $callback . ",\"" . $url . "\", \"" . $error . "\" );</script>";
 }
예제 #7
0
 /**
  * Update the specified resource in storage.
  *
  * @param Services $services
  * @param ServiceRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Services $services, ServiceRequest $request)
 {
     $oldImage = null;
     if ($request->file('upl')) {
         $oldImage = Attachment::where('id', $services->attachment_id);
         $imageModel = ImageUploadFacade::attachmentUpload($request->file('upl'), new Attachment(), 'services');
         $services->attachment_id = $imageModel->id;
     }
     $services->update($request->input());
     if ($oldImage) {
         $oldImage->delete();
     }
     return redirect()->route('admin.services.index');
 }
예제 #8
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(Banner $banner, BannerRequest $request)
 {
     $oldImage = null;
     if ($request->file('upl')) {
         $oldImage = Attachment::where('id', $banner->attachment_id);
         $imageModel = ImageUploadFacade::attachmentUpload($request->file('upl'), new Attachment(), 'banners');
         $banner->attachment_id = $imageModel->id;
     }
     $banner->paid = $request->paid == 'on' ? 1 : 0;
     $banner->update($request->input());
     if ($oldImage) {
         $oldImage->delete();
     }
     return redirect()->route('admin.banner.index');
 }
예제 #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Special $special, Requests\SpecialRequest $request)
 {
     $imageModel = ImageUploadFacade::attachmentUpload($request->file('upl'), new Attachment(), 'specials');
     $oldImage = null;
     if ($imageModel) {
         $oldImage = $special->attachment;
         $special->attachment()->associate($imageModel);
     }
     $special->update($request->input());
     if ($oldImage) {
         if (file_exists($oldImage->path)) {
             unlink($oldImage->path);
         }
         $oldImage->delete();
     }
     return redirect()->route('admin.special.index');
 }
예제 #10
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);
 }
예제 #11
0
 /**
  * Upload attachment to storage
  * 
  * @param Request $request
  * @return Response
  */
 public function uploadAttachment($request)
 {
     return ImageUploadFacade::attachmentUpload($request, new QuestionAttachment(), 'questions', true);
 }
예제 #12
0
 /**
  * @POST("shops/get_photos", middleware="auth")
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getPhotos(Request $request)
 {
     if ($request->s_id) {
         $shop_id = $request->s_id;
         \Session::put('shop_id', $shop_id);
     } else {
         $s_id = \Session::get('shop_id');
         $shop = Shops::find($s_id);
         if ($shop && !$shop->canAddItem()) {
             return redirect()->route('shops.my');
         }
         $file = ImageUploadFacade::attachmentUpload($request->file("file"), new Attachment(), 'shop_items');
         $item = new ShopItems();
         $item->name = 'Название';
         $item->description = 'Описание';
         $item->shop_id = $s_id;
         if ($file) {
             $item->attachment()->associate($file);
         }
         $item->save();
     }
     //return redirect()->route('shops.show', ['id'=>$request->id]);
 }
예제 #13
0
 /**
  * Store a newly created resource in storage.
  * POST /ads/upload
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //dd(\Request::input('editor1'));
     if (!Session::has('advertisements_hash')) {
         Session::put('advertisements_hash', md5(time()));
     }
     return Response::json(['attachment' => ImageUploadFacade::attachmentUpload($request->file('upl'), new AdsAttachment(), 'advertisements', true)]);
 }
예제 #14
0
 /**
  * Update the specified resource in storage.
  * @Middleware("auth")
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Request $request, $id)
 {
     $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new Attachment(), 'shop_items');
     $item = ShopItems::find($id);
     $item->fill($request->all());
     if ($attachment) {
         $item->attachment()->associate($attachment);
     }
     $item->save();
     return redirect()->away("/shopitems/{$request->shop_id}");
 }