app/Http/Controllers/AuditTrailController.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(Request $request, User $users)
    {
        $total_users = User::where('unitcode', Auth::user()->unitcode)->count();
        $users = User::where('unitcode', Auth::user()->unitcode)
                                    ->whereHas('roles', function ($query) {
                                        $query->where('name', 'logistics')
                                        ->orWhere('name', 'personnel');
                                    });
        $search = $request->get('search');
        if ($search != "") {
            $users = User::where('lastname', 'LIKE', '%' . $search . '%')->orWhere('firstname', 'LIKE', '%' . $search . '%')->where('unitcode', Auth::user()->unitcode)->latest()->paginate(10)->setPath('');
            if (isset($users)) {
                $pagination = $users->appends(array(
                    'search' => $request->get('search')
                ));
                if (count($users) > 0) {
                    return view('audittrail.index', 
                    [
                        'total_users' => $total_users,                 
                        'users' => $users
                    ])->withStatus($users)->withQuery($search);
                }
                $records = 'No';
                return view('audittrail.index', 
                [
                    'records' => $records, 
                    'total_users' => $total_users,                 
                    'users' => $users
                ])->withStatus($users)->withQuery($search);
            }
        }
        return view('audittrail.index', 
        [
            'total_users' => $total_users,    
            'users' => $users->latest()->paginate(10)
        ]);
    }
public function index ( Request $ request , User $ users ) { $ total_users = User :: where ( 'unitcode' , Auth :: user ( ) -> unitcode ) -> count ( ) ; $ users = User :: where ( 'unitcode' , Auth :: user ( ) -> unitcode ) -> whereHas ( 'roles' , function ( $ query ) { $ query -> where ( 'name' , 'logistics' ) -> orWhere ( 'name' , 'personnel' ) ; } ) ; $ search = $ request -> get ( 'search' ) ; if ( $ search != " " ) { $ users = User :: where ( 'lastname' , 'LIKE' , '%' . $ search . '%' ) -> orWhere ( 'firstname' , 'LIKE' , '%' . $ search . '%' ) -> where ( 'unitcode' , Auth :: user ( ) -> unitcode ) -> latest ( ) -> paginate ( 10 ) -> setPath ( '' ) ; if ( isset ( $ users ) ) { $ pagination = $ users -> appends ( array ( 'search' => $ request -> get ( 'search' ) ) ) ; if ( count ( $ users ) > 0 ) { return view ( 'audittrail.index' , [ 'total_users' => $ total_users , 'users' => $ users ] ) -> withStatus ( $ users ) -> withQuery ( $ search ) ; } $ records = 'No' ; return view ( 'audittrail.index' , [ 'records' => $ records , 'total_users' => $ total_users , 'users' => $ users ] ) -> withStatus ( $ users ) -> withQuery ( $ search ) ; } } return view ( 'audittrail.index' , [ 'total_users' => $ total_users , 'users' => $ users -> latest ( ) -> paginate ( 10 ) ] ) ; }
Display a listing of the resource.
Display a listing of the resource .