public function postSignup(Request $req) { $data = $req->all(); if ($data['password'] != $data['passwordRepeat'] && $data['password'] != '' && $data['email'] != '') { return response()->json(['input_error'], 400); } try { User::create(['email' => $data['email'], 'password' => bcrypt($data['password'])]); } catch (\Exception $e) { return response()->json(['db_error'], 400); } }
/** * Run the database seeds. * * @return void */ public function run() { $user = \SmartBell\User::create(['email' => '*****@*****.**', 'password' => bcrypt('123')]); $bell = \SmartBell\Bell::create(['name' => "Test Klingel", 'user_id' => $user->id, 'active' => 1, 'uuid' => Uuid::generate(1)->string]); $bell->name = "Test Klingel"; $bell->user_id = $user->id; $bell->active = true; $bell->save(); for ($i = 0; $i < 10; $i++) { \SmartBell\Ring::create(['user_id' => $user->id, 'bell_id' => $bell->id, 'file' => '']); } }
/** * 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'])]); }