app/Http/Controllers/DepartamentosController.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)
    {
        $this->validate($request, [
            'nombreDepartamento' => 'required|max:255',
            'nombreEncargado' => 'required',
            'apellidoPEncargado' => 'required',
            'apellidoMEncargado' => 'required',
            'selloimg' => 'required|image',
            'firmaimg' => 'required|image',
        ]);
        if ($request->hasFile('selloimg') && $request->hasFile('firmaimg')  ) {
            $image = $request->file('selloimg');
            $name = 'sello-'. $request->nombreDepartamento. '.' . $image->getClientOriginalExtension();
            $destinationPath = public_path('/img');
            $image->move($destinationPath, $name);
            $request['sello'] = $name;
            $imagefirma = $request->file('firmaimg');
            $namefirma = 'firma-'. $request->nombreDepartamento. '.' . $imagefirma->getClientOriginalExtension();
            $destinationPathfirma = public_path('/img');
            $imagefirma->move($destinationPathfirma, $namefirma);
            $request['firma'] = $namefirma;
            Departamentos::create($request->all());
            return redirect()->route('departamentos.index')->with('mensaje', 'departamento agregado con exito');
        }
        return redirect()->route('departamentos.index')->with('mensaje', 'hubo un problema al agregr departamento');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'nombreDepartamento' => 'required|max:255' , 'nombreEncargado' => 'required' , 'apellidoPEncargado' => 'required' , 'apellidoMEncargado' => 'required' , 'selloimg' => 'required|image' , 'firmaimg' => 'required|image' , ] ) ; if ( $ request -> hasFile ( 'selloimg' ) && $ request -> hasFile ( 'firmaimg' ) ) { $ image = $ request -> file ( 'selloimg' ) ; $ name = 'sello-' . $ request -> nombreDepartamento . '.' . $ image -> getClientOriginalExtension ( ) ; $ destinationPath = public_path ( '/img' ) ; $ image -> move ( $ destinationPath , $ name ) ; $ request [ 'sello' ] = $ name ; $ imagefirma = $ request -> file ( 'firmaimg' ) ; $ namefirma = 'firma-' . $ request -> nombreDepartamento . '.' . $ imagefirma -> getClientOriginalExtension ( ) ; $ destinationPathfirma = public_path ( '/img' ) ; $ imagefirma -> move ( $ destinationPathfirma , $ namefirma ) ; $ request [ 'firma' ] = $ namefirma ; Departamentos :: create ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'departamentos.index' ) -> with ( 'mensaje' , 'departamento agregado con exito' ) ; } return redirect ( ) -> route ( 'departamentos.index' ) -> with ( 'mensaje' , 'hubo un problema al agregr departamento' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//