/** * 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(); } }
/** * 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'])]); }
/** * 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')); }