/** * Update the specified photo in the database. * * @param int $albumId Id of the album * @param int $photoId Id of the photo * @return \Illuminate\View\View */ public function update(Request $request, $albumId, $photoId) { $this->validate($request, ['album_id' => 'required', 'photo_name' => 'required', 'photo_description' => 'max:255']); $photo = new Entity\Photo(); $photo->map(['id' => $photoId, 'album_id' => $request->input('album_id'), 'name' => $request->input('photo_name'), 'description' => $request->input('photo_description'), 'order' => 0]); \Gallery::photo()->save($photo); return \Redirect::route('gallery.album.photo.show', ['albumId' => $albumId, 'photoId' => $photoId])->with('alertsuccess', \Lang::get('gallery::gallery.update')); }
public function createPhoto($data = null, $add = true) { $faker = \Faker\Factory::create(); $photo = new Entity\Photo(); $metadata = ['id' => $faker->unique()->randomDigitNotNull(), 'name' => $faker->name, 'description' => $faker->sentence(3), 'file' => $faker->imageUrl(640, 480), 'size' => '640x480', 'album_id' => $faker->unique()->randomDigitNotNull()]; if (!is_null($data)) { foreach ($data as $key => $value) { $metadata[$key] = $value; } } $photo->map($metadata); if ($add) { $this->photos->add($photo); } return $photo; }
public function delete(Entity\Photo $photo) { return Photo::withTrashed()->where('id', $photo->getId())->forceDelete(); }