From fb334b237781f06ca9b0e5cbb19deca34a9e36ce Mon Sep 17 00:00:00 2001 From: miftahurrahmi Date: Tue, 30 Jan 2024 09:46:54 +0700 Subject: [PATCH 1/4] update permission seeder --- src/Commands/BadasoContentSetup.php | 8 ++++++-- src/Seeder/BadasoContentPermissionsSeeder.php | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Commands/BadasoContentSetup.php b/src/Commands/BadasoContentSetup.php index 4685d7d..6d6beda 100644 --- a/src/Commands/BadasoContentSetup.php +++ b/src/Commands/BadasoContentSetup.php @@ -58,7 +58,11 @@ private function generateSeeder() '--force' => $this->force, ]); - $this->call('l5-swagger:generate'); + try { + $this->call('l5-swagger:generate'); + } catch (\Exception $e) { + //throw $th; + } } private function hiddenTableHandle() @@ -71,7 +75,7 @@ private function hiddenTableHandle() $content_config = VarExporter::export($hidden_table); $content_config = << $key, - 'table_name' => 'content', - 'description' => 'Fill content', + 'table_name' => null, ]); } From 2cabcbaad448ab1857ee8f709c8a0494d2b59353 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 30 Jan 2024 02:48:33 +0000 Subject: [PATCH 2/4] Apply fixes from StyleCI --- src/Controllers/ContentController.php | 14 +- src/Swagger/content.php | 94 ++++---- tests/Feature/BadasoContentApiTest.php | 314 ++++++++++++------------- 3 files changed, 216 insertions(+), 206 deletions(-) diff --git a/src/Controllers/ContentController.php b/src/Controllers/ContentController.php index 0521a79..0d89ef8 100644 --- a/src/Controllers/ContentController.php +++ b/src/Controllers/ContentController.php @@ -35,8 +35,8 @@ public function read(Request $request) $content = Content::where('id', $request->id)->first(); $data = [ - 'id' => $content->id, - 'slug' => $content->slug, + 'id' => $content->id, + 'slug' => $content->slug, 'label' => $content->label, 'value' => json_decode($content->value), ]; @@ -92,7 +92,7 @@ public function add(Request $request) try { $request->validate([ - 'slug' => 'required|string|unique:Uasoft\Badaso\Module\Content\Models\Content', + 'slug' => 'required|string|unique:Uasoft\Badaso\Module\Content\Models\Content', 'label' => 'required|string', 'value' => 'required', ]); @@ -119,8 +119,8 @@ public function edit(Request $request) try { $request->validate([ - 'id' => 'required|exists:Uasoft\Badaso\Module\Content\Models\Content', - 'slug' => 'required|string|exists:Uasoft\Badaso\Module\Content\Models\Content', + 'id' => 'required|exists:Uasoft\Badaso\Module\Content\Models\Content', + 'slug' => 'required|string|exists:Uasoft\Badaso\Module\Content\Models\Content', 'label' => 'required|string', 'value' => 'required', ]); @@ -147,8 +147,8 @@ public function fill(Request $request) try { $request->validate([ - 'id' => 'required|exists:Uasoft\Badaso\Module\Content\Models\Content,id', - 'slug' => 'required|string|exists:Uasoft\Badaso\Module\Content\Models\Content,slug', + 'id' => 'required|exists:Uasoft\Badaso\Module\Content\Models\Content,id', + 'slug' => 'required|string|exists:Uasoft\Badaso\Module\Content\Models\Content,slug', 'label' => 'required|string', 'value' => 'required', ]); diff --git a/src/Swagger/content.php b/src/Swagger/content.php index dc05eeb..39661b3 100644 --- a/src/Swagger/content.php +++ b/src/Swagger/content.php @@ -7,6 +7,7 @@ * tags={"content"}, * summary="Browse Content", * description="Browse Content", + * * @OA\Response(response=200, description="Successful operation"), * @OA\Response(response=400, description="Bad request"), * @OA\Response(response=401, description="Unauthorized"), @@ -24,14 +25,17 @@ * tags={"content"}, * summary="Read Content", * description="Read Content", + * * @OA\Parameter( * name="id", * required=true, * in="query", + * * @OA\Schema( * type="string" * ) * ), + * * @OA\Response(response=200, description="Successful operation"), * @OA\Response(response=400, description="Bad request"), * @OA\Response(response=401, description="Unauthorized"), @@ -42,46 +46,52 @@ * ) */ - /** - * @OA\Get( - * path="/module/content/v1/content/fetch", - * operationId="browseModuleContentV1ContentFetch", - * tags={"content"}, - * summary="Fetch Content", - * description="Fetch Content", - * @OA\Parameter( - * name="slug", - * required=true, - * in="query", - * @OA\Schema( - * type="string" - * ) - * ), - * @OA\Response(response=200, description="Successful operation"), - * @OA\Response(response=400, description="Bad request"), - * @OA\Response(response=401, description="Unauthorized"), - * @OA\Response(response=402, description="Payment Required"), - * ) - */ +/** + * @OA\Get( + * path="/module/content/v1/content/fetch", + * operationId="browseModuleContentV1ContentFetch", + * tags={"content"}, + * summary="Fetch Content", + * description="Fetch Content", + * + * @OA\Parameter( + * name="slug", + * required=true, + * in="query", + * + * @OA\Schema( + * type="string" + * ) + * ), + * + * @OA\Response(response=200, description="Successful operation"), + * @OA\Response(response=400, description="Bad request"), + * @OA\Response(response=401, description="Unauthorized"), + * @OA\Response(response=402, description="Payment Required"), + * ) + */ - /** - * @OA\Get( - * path="/module/content/v1/content/fetch-multiple", - * operationId="browseModuleContentV1ContentFetchMultiple", - * tags={"content"}, - * summary="Fetch Multiple Content", - * description="Fetch Multiple Content", - * @OA\Parameter( - * name="slug", - * required=true, - * in="query", - * @OA\Schema( - * type="string" - * ) - * ), - * @OA\Response(response=200, description="Successful operation"), - * @OA\Response(response=400, description="Bad request"), - * @OA\Response(response=401, description="Unauthorized"), - * @OA\Response(response=402, description="Payment Required"), - * ) - */ +/** + * @OA\Get( + * path="/module/content/v1/content/fetch-multiple", + * operationId="browseModuleContentV1ContentFetchMultiple", + * tags={"content"}, + * summary="Fetch Multiple Content", + * description="Fetch Multiple Content", + * + * @OA\Parameter( + * name="slug", + * required=true, + * in="query", + * + * @OA\Schema( + * type="string" + * ) + * ), + * + * @OA\Response(response=200, description="Successful operation"), + * @OA\Response(response=400, description="Bad request"), + * @OA\Response(response=401, description="Unauthorized"), + * @OA\Response(response=402, description="Payment Required"), + * ) + */ diff --git a/tests/Feature/BadasoContentApiTest.php b/tests/Feature/BadasoContentApiTest.php index 1878cea..391b72f 100644 --- a/tests/Feature/BadasoContentApiTest.php +++ b/tests/Feature/BadasoContentApiTest.php @@ -25,7 +25,7 @@ public function test_add() $slug = 'This is Slug'."$i"; $label = 'This is label'."$i"; $request_data = [ - 'slug' => $slug, + 'slug' => $slug, 'label' => $label, 'value' => '{ "text":{ @@ -203,7 +203,7 @@ public function test_read() public function test_fetch() { $request_data = Content::latest()->first(); - $request_data = ['slug'=>$request_data->slug]; + $request_data = ['slug' => $request_data->slug]; $response = $this->json('GET', $this->getContentApiV1('/content/fetch'), $request_data); $response->assertSuccessful(); @@ -380,199 +380,199 @@ public function test_fill() 'label' => $table->label, 'value' => [ 'textedit' => [ - 'name' =>'textedit', - 'label' =>'texteditlabel', - 'type' =>'text', + 'name' => 'textedit', + 'label' => 'texteditlabel', + 'type' => 'text', 'data' => 'this is value text', ], - 'imageedit'=>[ - 'name'=>'imageedit', - 'label'=>'imageeditlabel', - 'type'=>'image', + 'imageedit' => [ + 'name' => 'imageedit', + 'label' => 'imageeditlabel', + 'type' => 'image', 'data' => 'News baru (1).jpg', ], - 'urledit'=>[ - 'name'=>'urledit', - 'label'=>'urleditlabel', - 'type'=>'url', - 'data'=>[ + 'urledit' => [ + 'name' => 'urledit', + 'label' => 'urleditlabel', + 'type' => 'url', + 'data' => [ 'url' => 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405', 'text' => '405 not permission', ], ], - 'groupedit'=>[ - 'name'=>'groupedit', - 'label'=>'groupeditlabel', - 'type'=>'group', - 'data'=>[ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=>'this is value in group text', + 'groupedit' => [ + 'name' => 'groupedit', + 'label' => 'groupeditlabel', + 'type' => 'group', + 'data' => [ + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'this is value in group text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ 'url' => 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405', 'text' => 'this is url in group url', ], - 'image'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=>'News baru (1).jpg', + 'image' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'News baru (1).jpg', ], ], ], ], - 'arrayedit'=>[ - 'name'=> 'arrayedit', - 'label'=> 'arrayedit', - 'type'=>'array', - 'data'=>[ + 'arrayedit' => [ + 'name' => 'arrayedit', + 'label' => 'arrayedit', + 'type' => 'array', + 'data' => [ [ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=>'data array text', + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'data array text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ - 'url'=> 'url array data', - 'text'=> 'data array text', + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ + 'url' => 'url array data', + 'text' => 'data array text', ], - ], 'img'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=> 'data array image', - ], 'grup'=>[ - 'name'=>'this is group', - 'label'=>'this is group', - 'type'=>'group', - 'data'=>[ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=> 'data group array text', + ], 'img' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'data array image', + ], 'grup' => [ + 'name' => 'this is group', + 'label' => 'this is group', + 'type' => 'group', + 'data' => [ + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'data group array text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ - 'url'=> 'data group url array', - 'text'=> 'data group url array text', + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ + 'url' => 'data group url array', + 'text' => 'data group url array text', ], - ], 'img'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=> 'data group array image', + ], 'img' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'data group array image', ], ], ], ], [ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=>'data second text', + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'data second text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ - 'url'=> 'data url second data', - 'text'=> 'data url second text', + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ + 'url' => 'data url second data', + 'text' => 'data url second text', ], - ], 'img'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=> 'data second image', - ], 'grup'=>[ - 'name'=>'this is group', - 'label'=>'this is group', - 'type'=>'group', - 'data'=>[ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=> 'data group second text', + ], 'img' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'data second image', + ], 'grup' => [ + 'name' => 'this is group', + 'label' => 'this is group', + 'type' => 'group', + 'data' => [ + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'data group second text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ - 'url'=> 'data group url second data', - 'text'=> 'data group url second text', + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ + 'url' => 'data group url second data', + 'text' => 'data group url second text', ], - ], 'img'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=> 'data group second image', + ], 'img' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'data group second image', ], ], ], ], [ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=>'data third text', + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'data third text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ - 'url'=> 'data url third data', - 'text'=> 'data url third text', + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ + 'url' => 'data url third data', + 'text' => 'data url third text', ], - ], 'img'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=> 'data third image', - ], 'grup'=>[ - 'name'=>'this is group', - 'label'=>'this is group', - 'type'=>'group', - 'data'=>[ - 'text'=>[ - 'name'=>'text', - 'label'=>'text', - 'type'=>'text', - 'data'=> 'data group third text', + ], 'img' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'data third image', + ], 'grup' => [ + 'name' => 'this is group', + 'label' => 'this is group', + 'type' => 'group', + 'data' => [ + 'text' => [ + 'name' => 'text', + 'label' => 'text', + 'type' => 'text', + 'data' => 'data group third text', ], - 'url'=>[ - 'name'=>'url', - 'label'=>'url', - 'type'=>'url', - 'data'=>[ - 'url'=> 'data group url third data', - 'text'=> 'data group url third text', + 'url' => [ + 'name' => 'url', + 'label' => 'url', + 'type' => 'url', + 'data' => [ + 'url' => 'data group url third data', + 'text' => 'data group url third text', ], - ], 'img'=>[ - 'name'=>'img', - 'label'=>'img', - 'type'=>'image', - 'data'=> 'data group third image', + ], 'img' => [ + 'name' => 'img', + 'label' => 'img', + 'type' => 'image', + 'data' => 'data group third image', ], ], ], @@ -643,7 +643,7 @@ public function test_fetch_multiple() $slug[] = $value->slug; } - $request_data = ['slug'=>join(',', $slug)]; + $request_data = ['slug' => join(',', $slug)]; $response = $this->json('GET', $this->getContentApiV1('/content/fetch-multiple'), $request_data); $response->assertSuccessful(); From 2ea8ab6c180a3a91337c84aff0d6e6745cb1ab35 Mon Sep 17 00:00:00 2001 From: miftahurrahmi Date: Tue, 30 Jan 2024 16:11:37 +0700 Subject: [PATCH 3/4] update --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4fb28eb..4f41b23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,9 +78,9 @@ jobs: - name: Laravel file configuration run: git branch && cd laravel && - composer require badaso/core:^2.0 && + composer require badaso/core:^2.0 -W && composer require badaso/content-module:dev-${GITHUB_HEAD_REF} && - composer update --no-interaction + composer update --no-interaction -W # Mysql | Laravel setup - name: Mysql | Laravel setup @@ -117,7 +117,7 @@ jobs: php artisan db:wipe && php artisan migrate && php artisan db:seed --class="Database\Seeders\Badaso\BadasoSeeder" && - php artisan db:seed --class="Database\Seeders\Badaso\Content\BadasoContentModuleSeeder" + php artisan db:seed --class="Database\Seeders\Badaso\Content\BadasoContentModuleSeeder" # Sqlite | Badaso Content Module test - name: Sqlite | Badaso Content Module test @@ -142,8 +142,8 @@ jobs: php artisan db:wipe && php artisan migrate && php artisan db:seed --class="Database\Seeders\Badaso\BadasoSeeder" && - php artisan db:seed --class="Database\Seeders\Badaso\Content\BadasoContentModuleSeeder" - + php artisan db:seed --class="Database\Seeders\Badaso\Content\BadasoContentModuleSeeder" + # Pgsql | Badaso Content Module test - name: Pgsql | Badaso Content Module test run: cd laravel && php artisan test From 509039a6f9276313f9f20f449c8df1f706b7f5b0 Mon Sep 17 00:00:00 2001 From: miftahurrahmi Date: Mon, 19 Feb 2024 09:04:04 +0700 Subject: [PATCH 4/4] update permission seeder --- src/Seeder/BadasoContentPermissionsSeeder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Seeder/BadasoContentPermissionsSeeder.php b/src/Seeder/BadasoContentPermissionsSeeder.php index d4a00ba..bd0b967 100644 --- a/src/Seeder/BadasoContentPermissionsSeeder.php +++ b/src/Seeder/BadasoContentPermissionsSeeder.php @@ -19,6 +19,7 @@ public function run() foreach ($keys as $key) { Permission::firstOrCreate([ 'key' => $key, + 'description' => 'Fill content', 'table_name' => null, ]); }