Exemplo n.º 1
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'])]);
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = User::findOrFail($id);
     $message = "";
     try {
         $user->delete();
         $message = trans('appstrings.item_removed', ['item' => $user->username]);
         Session::flash('message_type', 'success');
     } catch (\PDOException $e) {
         $message = trans('sqlmessages.' . $e->getCode());
         if ($message == 'sqlmessages.' . $e->getCode()) {
             $message = trans('sqlmessages.undefined');
         }
         if ($request->ajax()) {
             return ['code' => 'error', 'message' => $message];
         }
         Session::flash('message_type', 'error');
     }
     if ($request->ajax()) {
         return ['code' => 'ok', 'message' => $message];
     }
     Session::flash('message', $message);
     return redirect()->route('admin.users.index');
 }