create() публичный Метод

Create a new user instance after a valid registration.
public create ( array $data ) : User
$data array
Результат app\models\User
 public function register(Request $request)
 {
     $email = $request->input('email');
     $password = $request->input('password');
     $user = array('email' => $email, 'password' => $password, 'name' => $email);
     $object = new AuthController();
     $newUser = $object->create($user);
     return Response::json(array('result' => $newUser));
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param AuthController $auth
  * @internal param Request $request
  * @return Response
  */
 public function store(AuthController $auth)
 {
     $data = Input::all();
     $valid = $auth->validator($data);
     if ($valid->fails()) {
         return redirect()->back()->withInput()->withErrors($valid);
     }
     $user = $auth->create($data);
     Auth::login($user);
     return redirect()->to('admin');
 }
Пример #3
0
 /**
  * Store a new school.
  *
  * @param AddSchoolFormRequest $request
  * @return Response
  */
 public function addSchool(AddSchoolFormRequest $request)
 {
     $school = School::create(['name' => $request->school, 'town_id' => $request->town]);
     $user = new AuthController();
     $data = $request->all();
     $data['class'] = -1;
     $data['role'] = 1;
     $data['school'] = $school->id;
     $data['is_moderated'] = 1;
     $user->create($data);
     return redirect(route('home'));
 }
 public function create(Request $request)
 {
     // $result = $this->tokensMatch($request);
     // return Response::json(array('result' => $result ));
     $email = $request->input('email');
     $password = $request->input('password');
     $status = $request->input('status');
     $user = array('email' => $email, 'password' => $password, 'name' => $email, 'status' => $status);
     $object = new AuthController();
     $newUser = $object->create($user);
     return Response::json(array('result' => true, 'data' => $newUser));
 }
Пример #5
0
 /**
  * Register user
  * @param Request $request
  * @return token
  */
 public function postRegister(Request $request)
 {
     $validator = AuthController::validator($request->all());
     if ($validator->fails()) {
         return response()->json(['Email is already registered / Something wrong with input.'], 403);
     }
     //create user
     $user = AuthController::create($request->all());
     //credentials for login
     $credentials = $request->only('email', 'password');
     $token = $this->loginUser($credentials);
     return response()->json(compact('token'));
 }