app/Http/Controllers/Admin/EmployeeController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        if(Auth::user()->companyProfile->count() == 0)
            return redirect()->route('admin.profile')->withErrors(['error' => 'Provide company profile first']);
        $employees = User::role(['conductor', 'operation', 'driver'])->with('roles')
            ->whereHas('companyProfile', function($query){
                $query->where('bus_company_profiles.id', Auth::user()->company()->id);
            })
            ->has('employeeProfile')
            ->get();
        return view('admin.employees.index', compact('employees'));
    }
public function index ( ) { if ( Auth :: user ( ) -> companyProfile -> count ( ) == 0 ) return redirect ( ) -> route ( 'admin.profile' ) -> withErrors ( [ 'error' => 'Provide company profile first' ] ) ; $ employees = User :: role ( [ 'conductor' , 'operation' , 'driver' ] ) -> with ( 'roles' ) -> whereHas ( 'companyProfile' , function ( $ query ) { $ query -> where ( 'bus_company_profiles.id' , Auth :: user ( ) -> company ( ) -> id ) ; } ) -> has ( 'employeeProfile' ) -> get ( ) ; return view ( 'admin.employees.index' , compact ( 'employees' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .