示例#1
0
 public function apiVolunteerPlaces($req, $res)
 {
     $route = new ApiRoute();
     $route->addQueryParams(['module' => 'volunteers', 'model' => 'app\\volunteers\\models\\VolunteerPlace'])->addParseSteps(['parseRequireJson', 'parseRequireFindPermission', 'parseModelFindAllParameters', function ($route) {
         // determine type
         $type = $route->getRequest()->query('type');
         $where = $route->getQueryParams('where');
         if ($type == 'internal') {
             $where['place_type'] = VolunteerPlace::INTERNAL;
         } elseif ($type == 'external') {
             $where['place_type'] = VolunteerPlace::EXTERNAL;
         } elseif ($type == 'unapproved') {
             $where['place_type'] = VolunteerPlace::EXTERNAL;
             $where['verify_approved'] = false;
         }
         $route->addQueryParams(['where' => $where]);
     }])->addQueryStep('queryModelFindAll')->addTransformSteps(['transformModelFindAll', 'transformPaginate', 'transformOutputJson']);
     $route->execute($req, $res, $this->app);
 }