示例#1
0
 public function organizations($req, $res)
 {
     $app = $this->app;
     $user = $app['user'];
     $route = new ApiRoute();
     $route->addQueryParams(['model' => 'app\\volunteers\\models\\Volunteer', 'where' => ['organization IN ( SELECT id FROM Organizations )', 'uid' => $user->id(), 'role >= ' . Volunteer::ROLE_VOLUNTEER]])->addParseSteps(['parseRequireJson', 'parseModelFindAllParameters'])->addQueryStep('queryModelFindAll')->addTransformSteps(['transformModelFindAll', 'transformOutputJson']);
     $route->execute($req, $res);
 }
示例#2
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);
 }