app/Http/Controllers/AreaController.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)
    {
        $validator = $request->validate([
            'nomeArea' => 'required|string',
        ]);
        $area = Area::create([
            'nome' => $request->nomeArea,
        ]);
        foreach ($request->tipos as $key) {
            $areaTipoDocEmp = AreaTipodocemp::create([
                'area_id'       => $area->id,
                'tipodocemp_id' => $key,
            ]);
        }
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "1",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "2",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "3",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "4",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "5",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "6",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "7",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "8",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "9",]);
        $areaTipoDocEmp = AreaTipodocresp::create(['area_id' => $area->id, 'tipodocresp_id'=> "10",]);
        session()->flash('success', 'Área foi cadastrada!');
        return back();
    }
public function store ( Request $ request ) { $ validator = $ request -> validate ( [ 'nomeArea' => 'required|string' , ] ) ; $ area = Area :: create ( [ 'nome' => $ request -> nomeArea , ] ) ; foreach ( $ request -> tipos as $ key ) { $ areaTipoDocEmp = AreaTipodocemp :: create ( [ 'area_id' => $ area -> id , 'tipodocemp_id' => $ key , ] ) ; } $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 1 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 2 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 3 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 4 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 5 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 6 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 7 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 8 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 9 " , ] ) ; $ areaTipoDocEmp = AreaTipodocresp :: create ( [ 'area_id' => $ area -> id , 'tipodocresp_id' => " 10 " , ] ) ; session ( ) -> flash ( 'success' , 'Área foi cadastrada!') ; return back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .