/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $gallery = Gallery::find($id); $pictures = $gallery->pictures; // if (!Auth::user() || Auth::user()->id !== $gallery->user_id) { // $url = "/uzivatel/gallery/$id"; // return redirect($url); // } return response()->json(['data' => $pictures->toArray(), 'gallery_title' => $gallery->title, 'user' => $gallery->user->name, 'description' => $gallery->description]); }
public function postAddPhotos($id, Request $request) { $files = $request->files; foreach ($files as $file) { $path = '' . base_path() . '/pics/' . $id; $name = $file->getClientOriginalName(); $filename = $file->move($path, $name); $picture = Gallery::find($id)->pictures()->create(['url' => $file->getClientOriginalName()]); } $gallery = Gallery::find($id); $pics = $gallery->pictures; return response()->json(['data' => $pics->toArray()]); return response()->json(['status' => 'done']); }
/** * Remove image * * @param $id * @return \Illuminate\Http\JsonResponse */ public function destroyImage(Request $request) { if ($request->image_id) { $gallery_image = GalleryImages::find($request->image_id); if (File::exists(public_path() . '/admin/images/gallery/' . $gallery_image->name)) { File::delete(public_path() . '/admin/images/gallery/' . $gallery_image->name); } GalleryImages::destroy($gallery_image->id); } else { $gallery = Gallery::find($request->id); if (File::exists(public_path() . '/admin/images/gallery/' . $gallery->image)) { File::delete(public_path() . '/admin/images/gallery/' . $gallery->image); } $gallery->update(['image' => '']); } return response()->json(['message' => 'User image successfully deleted']); }
public function destroy($id) { $gallery = Gallery::find($id); $gallery->delete(); return redirect()->route('gallery.index'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function doImageUpload(Request $request) { //get the file from post request $file = $request->file('file'); //set my filename $filename = uniqid() . $file->getClientOriginalName(); //move file to corect location $file->move('gallery/images/', $filename); //save in db $gallery = Gallery::find($request->input('gallery_id')); $image = $gallery->images()->create(['gallery_id' => $request->input('gallery_id'), 'file_name' => $filename, 'file_size' => $file->getClientSize(), 'file_mime' => $file->getClientMimeType(), 'file_path' => 'Gallery/images/' . $filename, 'created_by' => Auth::user()->id]); return $image; }
/** * Удаление фотографии. * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function getDelete($id) { $photo = Gallery::find($id); if (empty($photo)) { abort(404); } // Удаляем изображение File::delete(public_path('assets' . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'galleries' . DIRECTORY_SEPARATOR . $photo->file_name)); $photo->delete(); return redirect()->back()->with('success', 'Фотография успешно удалена.'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function getShow($id) { // $photo = Gallery::find($id); return view('gallery.show', compact('photo')); }
public function postRemovePicture(AddPictureRequest $request) { Gallery::find($request["id"])->delete(); return redirect()->action('AdminController@getIndex'); }
public function gallery_show($id) { $gallery = Gallery::find($id); return view('Home.gallery_show', compact('gallery')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id_event, $id_photo) { if (Request::isMethod('get')) { $this->data = array(); $this->data['event'] = Event::find($id_event); $this->data['gallery'] = Gallery::find($id_photo); return View::make('admin.event.konten.gallery.delete', $this->data); } else { if (Request::isMethod('post')) { $data = Input::all(); Gallery::where('id', '=', $id_photo)->delete(); return redirect('admin/event/update/' . $id_event); } } }
public function previewGallery(Request $request) { return Gallery::find($request->input('id')); }
public static function getGalleryImages($galleryID) { $pp = \App\Gallery::find($galleryID)->descriptions; }