public function viewAlbumPics($id) { //showing the albums-details by its id $albums = Album::findOrFail($id); $photos = $albums->photos()->get(); return view('admin.album-details', compact('albums', 'photos')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $album = Album::findOrFail($id); $album->photos; //$album->photos->toArray(); return view('admin.album.show', compact('album')); }
public function upload(Request $request, $id) { $album = Album::findOrFail($id); $files = $request->file(); $file = $files['files'][0]; if (!$file->isValid()) { return new Response('Invalid Image ' . print_r($files, true), 400); } $destinationPath = app()->storagePath() . '/photos/'; $file->move($destinationPath, $file->getFilename()); $photo = Photo::create(['path' => $destinationPath . $file->getFilename(), 'name' => $file->getClientOriginalName(), 'album_id' => $album->id]); $photoArray = $photo->toArray(); $photoArray['url'] = '/photo/' . $photo->id; $photo->makeThumbnail(); return ['status' => 'done', 'files' => [$photoArray]]; }
public function postNotify(Request $request, $id) { /* @var $album \App\Album */ $album = Album::findOrFail($id); $user_ids = $request->input('user', []); $subject = $request->input('subject', ''); $message = $request->input('message', ''); $emails_sent = 0; foreach ($user_ids as $user_id) { $user = User::find($user_id); if ($user) { $emails_sent++; Mail::raw($message, function ($m) use($user, $subject) { $m->to($user->email); $m->subject($subject); }); } } return redirect('/albums')->with('success', "{$emails_sent} messages sent."); }
public function destroy($id) { $album = Album::findOrFail($id); if (Gate::denies('album_authorize', $album)) { return "authorize fails"; } foreach ($album->img as $albums) { File::delete(['uploads/' . $albums->name, 'uploads/thumbnails/' . 'thumbnail_' . $albums->name, 'uploads/' . $albums->thumbnail, 'uploads/thumbnails/' . $albums->thumbnail, 'uploads/' . $albums->thumbnail2, 'uploads/thumbnails/' . $albums->thumbnail2]); } Img::where('album_id', $album->id)->delete(); Album::destroy($id); return redirect('/admin/albums/'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $album = Album::findOrFail($id); $album->delete(); return redirect('/'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $album = Album::findOrFail($id); if (\Auth::user() == $album->user) { $photos = $album->photos; $this->deletePhotos($photos); $album->delete(); return redirect('album')->with('status', 'Album gelöscht!'); } else { abort(403, 'Unauthorized action.'); } }
/** * Show the form for creating a new resource. * * @return Response */ public function create($id) { $album = Album::findOrFail($id); return view('photos.create', compact('album')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $album = Album::findOrFail($id); try { File::delete(public_path() . '/uploads/albums/' . $album->thumbnail); $album->destroy($id); } catch (Exception $e) { App::abort(404); } return Redirect::route('admin.album.show'); }
/** * Metodo para criar uma nova foto e associar ao album * @param [type] $id [description] * @return [type] [description] */ public function adicionarFoto($id) { $album = Album::findOrFail($id); //Adicionando nova foto ao album de $id $file = Input::file('foto_upload'); dd($file); if ($file) { $destinationPath = public_path() . '/uploads/'; $filename = self::formatFileNameWithUserAndTimestamps($file->getClientOriginalName()); $upload_success = $file->move($destinationPath, $filename); if ($upload_success) { $foto = new Foto(['path' => $destinationPath . $filename, 'tipo' => 'avatar']); $album->fotos()->save($foto); } } }