Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update permission seeder #109

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions src/Commands/BadasoContentSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -71,7 +75,7 @@ private function hiddenTableHandle()
$content_config = VarExporter::export($hidden_table);
$content_config = <<<PHP
<?php

return {$content_config} ;
PHP;

Expand Down
14 changes: 7 additions & 7 deletions src/Controllers/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
Expand Down Expand Up @@ -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',
]);
Expand All @@ -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',
]);
Expand All @@ -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',
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Seeder/BadasoContentPermissionsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function run()
foreach ($keys as $key) {
Permission::firstOrCreate([
'key' => $key,
'table_name' => 'content',
'description' => 'Fill content',
'table_name' => null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it's changed to be null, what's the different ? @miftahurrahmi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the badaso_contents table encountered difficulties when generating processes in the permission table. When set to null, the permission generation process succeeded

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what difficulties ? please explain more detail

if table_name null, so how permission works ?

]);
}

Expand Down
94 changes: 52 additions & 42 deletions src/Swagger/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -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"),
* )
*/
Loading