/** * Run the database seeds. * * @return void */ public function run() { $users = User::all(); foreach ($users as $user) { $number = mt_rand(0, 15); for ($i = 0; $i < $number; $i++) { Album::create(['title' => "Title album {$i} of {$user->id}", 'description' => "Description album {$i} of {$user->id}", 'user_id' => $user->id]); } } }
public function postCreateAlbum(CreateAlbumRequest $request) { Album::create(['title' => $request->get('title'), 'description' => $request->get('description'), 'user_id' => auth()->user()->id]); return redirect('validated/albums/')->with(['album_created' => 'The Album has been created.']); }