示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->delete();
     $users = [['id' => 1, 'name' => 'System', 'email' => 'system@vinfo', 'password' => bcrypt('password'), 'is_admin' => true], ['id' => 2, 'name' => 'Admin', 'email' => 'admin@vinfo', 'password' => bcrypt('password'), 'is_admin' => true], ['id' => 3, 'name' => 'User', 'email' => 'user@vinfo', 'password' => bcrypt('password'), 'is_admin' => false]];
     $country = Country::whereCode('GB')->first();
     $language = Language::whereCode('en-GB')->first();
     $currency = Currency::whereCode('GBP')->first();
     foreach ($users as $userData) {
         $user = new User();
         $user->fill($userData);
         $user->country()->associate($country);
         $user->language()->associate($language);
         $user->currency()->associate($currency);
         $user->save();
     }
 }
示例#2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
示例#3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = User::findOrFail($id);
     $this->authorize('destroy', $user);
     if ($user->delete()) {
         return redirect(action('UsersController@index'))->with('success', trans('messages.deleted_success'));
     }
     return redirect(action('UsersController@edit', $user->id))->with('error', trans('messages.deleted_error'));
 }