app/Http/Controllers/UserController.php
/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(UserRequest $request)
  {
    try{
      $user = new User($request->all());
      $pass=substr(md5(microtime()),1,6);
      $user->password=bcrypt($pass);
      if($user->save()){
        $user->assignRole($request->role);
        Mail::send('administracion.email.usuario',['user'=>$user,'pass' => $pass ], function ($m) use ($user){
              $m->to($user->email,$user->primerNombre);
              $m->subject('Contraseña y nombre de usuario');
              $m->from('panonline503@gmail.com','Panadería Lila');
                                                  });
      }
     return redirect()->action('UserController@index')->with('info','Usuario Registrado')->with('tipo','success');
    }catch(Exception $e){
      return back()->with('msj2','Usuario no registrado, es posible que el username ya se encuentre registrado');
    }
  }
public function store ( UserRequest $ request ) { try { $ user = new User ( $ request -> all ( ) ) ; $ pass = substr ( md5 ( microtime ( ) ) , 1 , 6 ) ; $ user -> password = bcrypt ( $ pass ) ; if ( $ user -> save ( ) ) { $ user -> assignRole ( $ request -> role ) ; Mail :: send ( 'administracion.email.usuario' , [ 'user' => $ user , 'pass' => $ pass ] , function ( $ m ) use ( $ user ) { $ m -> to ( $ user -> email , $ user -> primerNombre ) ; $ m -> subject ( 'Contraseña y nombre de usuario') ; $ m -> from ( 'panonline503@gmail.com' , 'Panadería Lila') ; } ) ; } return redirect ( ) -> action ( 'UserController@index' ) -> with ( 'info' , 'Usuario Registrado' ) -> with ( 'tipo' , 'success' ) ; } catch ( Exception $ e ) { return back ( ) -> with ( 'msj2' , 'Usuario no registrado, es posible que el username ya se encuentre registrado' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//se modificará para hacer una contraseña aleatoria y mandar un correo con datos