@@ -54,6 +54,13 @@ public function __construct(
5454 * summary="Get all organisations (public)",
5555 * security={{"ApiKeyAuth": {}}},
5656 * tags={"Organisation"},
57+ * @OA\Parameter(
58+ * name="published",
59+ * in="query",
60+ * required=false,
61+ * description="Filter organisations by whether they have translations with published=true/false",
62+ * @OA\Schema(type="boolean")
63+ * ),
5764 * @OA\Response(
5865 * response=200,
5966 * description="Successful response",
@@ -67,8 +74,27 @@ public function __construct(
6774 public function getAll (Request $ request )
6875 {
6976 try {
77+ $ publishedParam = $ request ->query ('published ' , null );
78+ $ publishedFilter = null ;
79+
80+ if (!is_null ($ publishedParam )) {
81+ $ publishedFilter = filter_var ($ publishedParam , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE );
82+
83+ if (is_null ($ publishedFilter )) {
84+ return response ()->json ([
85+ 'status ' => 422 ,
86+ 'error_message ' => 'Invalid published filter. Use true or false. ' ,
87+ 'errors ' => ['published query param must be a boolean ' ],
88+ ], 422 );
89+ }
90+ }
91+
7092 /** @var Collection $orgs */
71- $ orgs = $ this ->orgRepo ->all ()->load ('details ' );
93+ if (!is_null ($ publishedFilter )) {
94+ $ orgs = $ this ->orgRepo ->allByTranslationPublished ($ publishedFilter )->load ('details ' );
95+ } else {
96+ $ orgs = $ this ->orgRepo ->all ()->load ('details ' );
97+ }
7298 } catch (\Exception $ e ) {
7399 Log::error ('Could not get Organisations list ' , ['message ' => $ e ->getMessage ()]);
74100
0 commit comments