app/Http/Controllers/Staff/WrenchController.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)
    {
        $validatedData = $request->validate([
            'firma_id' => 'required|numeric|min:1|max:999999999', 
            'cargo_id'  => 'required|numeric|min:1|max:999999999',
            'numeracion'  => 'required|numeric|min:1|max:9999999999999999999999999999999999',
            'certificado' =>'required|file',
            'llave' =>'required|file',
            'firma' => 'required|string|max:255',
            'edo' => 'required|numeric|min:0|max:1'
        ]);
        $responsable = new Responsable();
        $responsable->firma_id = $request->input('firma_id');
        $responsable->cargo_id = $request->input('cargo_id');
        $responsable->numeracion = $request->input('numeracion');
        $responsable->firma = $request->input('firma');
        $responsable->edo = $request->input('edo');
        if ( $request->file('certificado') ){
            $path_file_uploaded = UploadFilesResponsablesController::
                                  uploadCertificado( $request->file('certificado') );
            if ($path_file_uploaded)
                $responsable->certificado = $path_file_uploaded;
            else 
                return redirect()->route('wrench.index')->with('code', 304);
        } 
        if ( $request->file('llave') ){
            $path_file_uploaded = UploadFilesResponsablesController::
                                  uploadKey( $request->file('llave') );
            if ($path_file_uploaded)
                $responsable->llave = $path_file_uploaded;
            else 
                return redirect()->route('wrench.index')->with('code', 304);
        }
        $action = 'Responsable::create';
        $table  = 'responsables';
        if ( $save = $responsable->save() )
             if ( $this->history($save, $action, $table) )
                $response = 200;
            else    
                $response = 303; 
        else    
            $response = 302;
    return redirect()->route('wrench.index')->with('code', $response);
    }
public function store ( Request $ request ) { $ validatedData = $ request -> validate ( [ 'firma_id' => 'required|numeric|min:1|max:999999999' , 'cargo_id' => 'required|numeric|min:1|max:999999999' , 'numeracion' => 'required|numeric|min:1|max:9999999999999999999999999999999999' , 'certificado' => 'required|file' , 'llave' => 'required|file' , 'firma' => 'required|string|max:255' , 'edo' => 'required|numeric|min:0|max:1' ] ) ; $ responsable = new Responsable ( ) ; $ responsable -> firma_id = $ request -> input ( 'firma_id' ) ; $ responsable -> cargo_id = $ request -> input ( 'cargo_id' ) ; $ responsable -> numeracion = $ request -> input ( 'numeracion' ) ; $ responsable -> firma = $ request -> input ( 'firma' ) ; $ responsable -> edo = $ request -> input ( 'edo' ) ; if ( $ request -> file ( 'certificado' ) ) { $ path_file_uploaded = UploadFilesResponsablesController :: uploadCertificado ( $ request -> file ( 'certificado' ) ) ; if ( $ path_file_uploaded ) $ responsable -> certificado = $ path_file_uploaded ; else return redirect ( ) -> route ( 'wrench.index' ) -> with ( 'code' , 304 ) ; } if ( $ request -> file ( 'llave' ) ) { $ path_file_uploaded = UploadFilesResponsablesController :: uploadKey ( $ request -> file ( 'llave' ) ) ; if ( $ path_file_uploaded ) $ responsable -> llave = $ path_file_uploaded ; else return redirect ( ) -> route ( 'wrench.index' ) -> with ( 'code' , 304 ) ; } $ action = 'Responsable::create' ; $ table = 'responsables' ; if ( $ save = $ responsable -> save ( ) ) if ( $ this -> history ( $ save , $ action , $ table ) ) $ response = 200 ; else $ response = 303 ; else $ response = 302 ; return redirect ( ) -> route ( 'wrench.index' ) -> with ( 'code' , $ response ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//dd( $request->file('certificado')  ); /*CHECAMOS POR CADA UNA DE LAS VARIABLES FILE*/ /*SETEAMOS LA RUTA EN LA VAR DE LA DB*/ /*SETEAMOS LA RUTA EN LA VAR DE LA DB*/