app/Http/Controllers/RespTecnicoController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create(Request $request)
    {
        $empresa = Empresa::find($request->empresaId);
        $user = User::find(Auth::user()->id);
        $cnaeEmpresa = CnaeEmpresa::where('empresa_id', $request->empresaId)->get();
        $rtempresa = RtEmpresa::where('empresa_id', $request->empresaId)->get();
        $resptecnicos = [];
        foreach ($rtempresa as $indice) {
            array_push($resptecnicos, RespTecnico::find($indice->resptec_id));
        }
        $temp = array_unique($resptecnicos);
        $cnae = array();
        $areas = array();
        foreach($cnaeEmpresa as $indice){
            $cnaes = Cnae::find($indice->cnae_id);
            array_push($cnae, $cnaes);
        }
        foreach($cnae as $indice){
            $area = Area::find($indice->areas_id);
            array_push($areas, $area);
        }
        $resultAreasTemp = array_unique($areas);
        $areasOrdenado = [];
        foreach ($resultAreasTemp as $indice) {
            array_push($areasOrdenado, $indice);
        }
        return view('responsavel_tec.cadastrar_responsavel_tec')->with(["user" => $user,
            "empresaId"     => $request->empresaId,
            'areas'         => $areasOrdenado,
            'respTecnicos'  => $temp,
            'rtempresa'     => $rtempresa,
            'empresaNome'   => $empresa->nome,
        ]);
    }
public function create ( Request $ request ) { $ empresa = Empresa :: find ( $ request -> empresaId ) ; $ user = User :: find ( Auth :: user ( ) -> id ) ; $ cnaeEmpresa = CnaeEmpresa :: where ( 'empresa_id' , $ request -> empresaId ) -> get ( ) ; $ rtempresa = RtEmpresa :: where ( 'empresa_id' , $ request -> empresaId ) -> get ( ) ; $ resptecnicos = [ ] ; foreach ( $ rtempresa as $ indice ) { array_push ( $ resptecnicos , RespTecnico :: find ( $ indice -> resptec_id ) ) ; } $ temp = array_unique ( $ resptecnicos ) ; $ cnae = array ( ) ; $ areas = array ( ) ; foreach ( $ cnaeEmpresa as $ indice ) { $ cnaes = Cnae :: find ( $ indice -> cnae_id ) ; array_push ( $ cnae , $ cnaes ) ; } foreach ( $ cnae as $ indice ) { $ area = Area :: find ( $ indice -> areas_id ) ; array_push ( $ areas , $ area ) ; } $ resultAreasTemp = array_unique ( $ areas ) ; $ areasOrdenado = [ ] ; foreach ( $ resultAreasTemp as $ indice ) { array_push ( $ areasOrdenado , $ indice ) ; } return view ( 'responsavel_tec.cadastrar_responsavel_tec' ) -> with ( [ " user " => $ user , " empresaId " => $ request -> empresaId , 'areas' => $ areasOrdenado , 'respTecnicos' => $ temp , 'rtempresa' => $ rtempresa , 'empresaNome' => $ empresa -> nome , ] ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .