コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Model::unguard();
     User::truncate();
     Album::truncate();
     $this->call('UserTableSeeder');
     $this->call('AlbumTableSeeder');
 }
コード例 #2
0
 /**
  * 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]);
         }
     }
 }
コード例 #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Model::unguard();
     User::truncate();
     //delete the previous db data and then seed the db
     Album::truncate();
     $this->call('UserTableSeeder');
     $this->call('AlbumTableSeeder');
 }
コード例 #4
0
 public function postRecoverPassword(PasswordRecoveryRequest $request)
 {
     $question = $request->get('question');
     $answer = $request->get('answer');
     $user = User::where('email', $request->get('email'))->first();
     if ($user->question === $question && $user->answer === Hash::check($answer, $user->answer)) {
         $user->password = bcrypt($request->get('password'));
         $user->save();
         return redirect('auth/login')->with(['success' => 'The password was successfully changed.']);
     }
     return redirect('auth/recover-password')->withInput($request->only('email', 'question'))->withErrors('The answer or the question doesn\'t match.');
 }
コード例 #5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
コード例 #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 50; $i++) {
         User::create(['name' => "User {$i}", 'email' => "user{$i}@users.com", 'password' => bcrypt('pass'), 'question' => 'quest', 'answer' => bcrypt('answer')]);
     }
 }
コード例 #7
0
 /**
  * To display all the albums
  */
 public function getIndex()
 {
     $user_id = Auth::user()->id;
     $albums = User::find($user_id)->albums;
     return view('album.show', ['albums' => $albums]);
 }