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(Request $request)
    {
        if(!$request->ajax()) return \redirect('/');
        try {
            DB::beginTransaction();
            $persona = new Persona();
            $persona->nombre =$request->nombre;
            $persona->tipo_documento =$request->tipo_documento;
            $persona->num_documento =$request->num_documento;
            $persona->direccion =$request->direccion;
            $persona->telefono =$request->telefono;
            $persona->email =$request->email;
            $persona->save();
            $user = new User();
            $user->usuario = $request->usuario; 
            $user->password = \bcrypt($request->password); 
            $user->condicion = '1'; 
            $user->idrol = $request->idrol; 
            $user->id = $persona->id;
            $user->save();
            DB::commit();
        } catch (\Exception $e) {
            DB::roollBack();
        }
    }
public function store ( Request $ request ) { if ( ! $ request -> ajax ( ) ) return \ redirect ( '/' ) ; try { DB :: beginTransaction ( ) ; $ persona = new Persona ( ) ; $ persona -> nombre = $ request -> nombre ; $ persona -> tipo_documento = $ request -> tipo_documento ; $ persona -> num_documento = $ request -> num_documento ; $ persona -> direccion = $ request -> direccion ; $ persona -> telefono = $ request -> telefono ; $ persona -> email = $ request -> email ; $ persona -> save ( ) ; $ user = new User ( ) ; $ user -> usuario = $ request -> usuario ; $ user -> password = \ bcrypt ( $ request -> password ) ; $ user -> condicion = '1' ; $ user -> idrol = $ request -> idrol ; $ user -> id = $ persona -> id ; $ user -> save ( ) ; DB :: commit ( ) ; } catch ( \ Exception $ e ) { DB :: roollBack ( ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .