app/Http/Controllers/Empresa/UsuarioController.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, $id = null)
    {
        if (Auth::user()->hasRole('SuperAdministrador')) {
            $empresa = Empresa::find($id);
        } else {
            $empresa = Empresa::find(Auth::user()->empresa_id);
        }
        $usuario = null;
        if (Auth::user()->hasRole('Administrador')) {
            $roles = Role::orderBy('name')->whereNotIn('name', ['SuperAdministrador'])->get()->pluck('name', 'name');
        } else {
            $roles = Role::orderBy('name')->whereIn('name', ['Vendedor'])->get()->pluck('name', 'name');
        }
        return view('usuario.form', compact('empresa', 'id', 'usuario', 'roles'));
    }
public function create ( Request $ request , $ id = null ) { if ( Auth :: user ( ) -> hasRole ( 'SuperAdministrador' ) ) { $ empresa = Empresa :: find ( $ id ) ; } else { $ empresa = Empresa :: find ( Auth :: user ( ) -> empresa_id ) ; } $ usuario = null ; if ( Auth :: user ( ) -> hasRole ( 'Administrador' ) ) { $ roles = Role :: orderBy ( 'name' ) -> whereNotIn ( 'name' , [ 'SuperAdministrador' ] ) -> get ( ) -> pluck ( 'name' , 'name' ) ; } else { $ roles = Role :: orderBy ( 'name' ) -> whereIn ( 'name' , [ 'Vendedor' ] ) -> get ( ) -> pluck ( 'name' , 'name' ) ; } return view ( 'usuario.form' , compact ( 'empresa' , 'id' , 'usuario' , 'roles' ) ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .