Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  * POST /gallery
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::only(['title', 'body']);
     $rules = ['title' => 'required', 'body' => 'required'];
     $validation = Validator::make($data, $rules);
     if ($validation->fails()) {
         return Redirect::back()->withInput()->withErrors($validation->messages());
     } else {
         $gallery = new Gallery($data);
         $gallery->available = true;
         $gallery->slug = \Str::slug($data['title']);
         $gallery->save();
     }
     return Redirect::route('gallery', [$gallery->slug, $gallery->id])->with(['confirm' => 'Se inserto el registro correctamente.']);
 }
Esempio n. 2
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $title = $faker->sentence($nbWords = 6);
         $gallery = Gallery::create(['title' => $title, 'body' => $faker->text($maxNbChars = 200), 'slug' => \Str::slug($title), 'available' => true]);
         foreach (range(1, 5) as $index) {
             Photo::create(['title' => $faker->sentence($nbWords = 6), 'image_url' => $faker->randomElement(['images/assets/2014/4.jpg', 'images/assets/2014/5.jpg', 'images/assets/2014/6.jpg']), 'gallery_id' => $gallery->id]);
         }
     }
 }
Esempio n. 3
0
 public function listar($take = 10)
 {
     return Gallery::orderBy('created_at', 'desc')->with('photos')->paginate();
 }