app/Http/Controllers/Approval/ApprovalRequests.php
//shows all requests for an authorizer
shows all requests for an authorizer
shows all requests for an authorizer
public function authorizersIndex(Request $request, Manager $fractal){
        $search = $request->query('search');
        $limit = $request->query('limit', 10);
        $pagingAppends = ['limit' => $limit];
        $company = $this->company();
        $user = $company->users()->where('uuid',$request->query('user_id'))->firstOrFail();
        $approvalRequests = $this->getRequests($user);
        if($approvalRequests->isEmpty()){
            throw new NotFoundHttpException('no current request awaits your approval');
        }
        $builder = $approvalRequests;
        $resource = new Collection($builder, new ApprovalRequestsTransformer(), 'approvalRequests');
        return response()->json($fractal->createData($resource)->toArray(),200);
    }
public function authorizersIndex ( Request $ request , Manager $ fractal ) { $ search = $ request -> query ( 'search' ) ; $ limit = $ request -> query ( 'limit' , 10 ) ; $ pagingAppends = [ 'limit' => $ limit ] ; $ company = $ this -> company ( ) ; $ user = $ company -> users ( ) -> where ( 'uuid' , $ request -> query ( 'user_id' ) ) -> firstOrFail ( ) ; $ approvalRequests = $ this -> getRequests ( $ user ) ; if ( $ approvalRequests -> isEmpty ( ) ) { throw new NotFoundHttpException ( 'no current request awaits your approval' ) ; } $ builder = $ approvalRequests ; $ resource = new Collection ( $ builder , new ApprovalRequestsTransformer ( ) , 'approvalRequests' ) ; return response ( ) -> json ( $ fractal -> createData ( $ resource ) -> toArray ( ) , 200 ) ; }
shows all requests for an authorizer
shows all requests for an authorizer
# get the search term in the query, if any # the maximum number of customers to return # retrieve the company # add the append terms # set the paginator