/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = Usuario::create(['nome' => $data['nome'], 'sobrenome' => $data['sobrenome'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); $role = Defender::findRole('gestor'); $user->attachRole($role); return $user; }
/** * Run the database seeds. * * @return void */ public function run() { \SisMid\Models\Usuario::create(['nome' => 'Admin', 'sobrenome' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt('admin')]); $today = \Carbon\Carbon::now(); DB::table('roles')->insert(['id' => 1, 'name' => 'admin', 'created_at' => $today, 'updated_at' => $today]); DB::table('roles')->insert(['id' => 2, 'name' => 'gestor', 'created_at' => $today, 'updated_at' => $today]); DB::table('role_user')->insert(['role_id' => 1, 'user_id' => 1]); // \SisMid\Models\Usuario::create([ // 'nome' => 'teste', // 'sobrenome' => 'teste', // 'email' => '*****@*****.**', // 'password' => bcrypt('teste') // ]); }
public function storeGerenciaAdmin(Request $request) { $this->validate($request, ['nome' => 'required|max:255', 'sobrenome' => 'required|max:255', 'email' => 'required|email|max:255']); $password = str_random(8); $user = Usuario::create(['nome' => $request['nome'], 'sobrenome' => $request['sobrenome'], 'email' => $request['email'], 'password' => bcrypt($password)]); $role = Defender::findRole('admin'); $user->attachRole($role); Mail::send('emails.newUser', ['nome' => $request['nome'], 'email' => $request['email'], 'senha' => $password], function ($m) use($request) { $m->to($request['email'], $request['nome'])->subject('Bem vindo ao SisMid'); }); return redirect(route("admin.gerencia.index"))->with(['flash_type_message' => 'alert-success', 'flash_message' => 'Administrador cadastrado com sucesso']); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { $this->validate($request, ['nome' => 'required|min:3|max:255', 'sobrenome' => 'required|min:3|max:255', 'email' => 'required|email|unique:usuarios,email,' . $request['idUsuario'] . ',idUsuario', 'iniciativa_id' => 'required|exists:iniciativas,idIniciativa']); $usuario = Usuario::findOrFail($request['idUsuario']); $usuario->update($request->all()); return $this->show($usuario->idUsuario); }