From 69c72b68b6d3496c565a3692a7b25311bb4318f4 Mon Sep 17 00:00:00 2001 From: Daniel Pett Date: Fri, 27 May 2022 00:06:12 +0100 Subject: [PATCH] Add simple research method --- app/Http/Controllers/homeController.php | 2 +- app/Models/ResearchProjects.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/homeController.php b/app/Http/Controllers/homeController.php index 25a33a0d..d0d74cd0 100644 --- a/app/Http/Controllers/homeController.php +++ b/app/Http/Controllers/homeController.php @@ -29,7 +29,7 @@ public function index(): View $galleries = Galleries::list(3, '?'); $exhibitions = Exhibitions::listHome('current', 'tessitura_string', 3); $news = NewsArticles::feature(); - $research = ResearchProjects::list('?', 3); + $research = ResearchProjects::listSimple('?', 3); $fundraising = FundRaising::list(4); $objects = Highlights::homeList(); $things = ThingsToDo::list(); diff --git a/app/Models/ResearchProjects.php b/app/Models/ResearchProjects.php index c0517764..d188bd6e 100644 --- a/app/Models/ResearchProjects.php +++ b/app/Models/ResearchProjects.php @@ -70,4 +70,24 @@ public static function findByDepartment(): array ); return $api->getData(); } + + /** + * @param string $sort + * @param int $limit + * @return array + */ + public static function listSimple(string $sort = 'title', int $limit = 100): array + { + $api = new DirectUs; + $api->setEndpoint('research_projects'); + $api->setArguments( + array( + 'fields' => '*.*.*.*', + 'meta' => 'result_count,total_count,type', + 'sort' => $sort, + 'limit' => $limit + ) + ); + return $api->getData(); + } }