/** * @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)]); }
/** * 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; } }
/** * 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'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Category $categories, CategoryRequest $request) { $categories->fill($request->all()); if ($request->file('attachment') !== null) { $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new Attachment(), 'categories', true); $categories->attachment()->associate($attachment); } $categories->save(); return redirect()->route('admin.categories.index'); }
/** * 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'); }
/** * 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'); }
/** * 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'); }
/** * @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); }
/** * Upload attachment to storage * * @param Request $request * @return Response */ public function uploadAttachment($request) { return ImageUploadFacade::attachmentUpload($request, new QuestionAttachment(), 'questions', true); }
/** * @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]); }
/** * 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)]); }
/** * 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}"); }