From b2e6743903ebf41897ae13dc6958536f8e5ff9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Tue, 12 Mar 2024 13:08:51 +0100 Subject: [PATCH 1/3] Add model fields to course model --- src/Http/Requests/CreateCourseAPIRequest.php | 3 +- src/Http/Requests/UpdateCourseAPIRequest.php | 3 +- .../Admin/CourseWithProgramAdminResource.php | 3 + src/Http/Resources/CourseListResource.php | 3 + src/Http/Resources/CourseResource.php | 3 + src/Http/Resources/CourseSimpleResource.php | 3 + .../Resources/CourseWithProgramResource.php | 3 + src/Models/Course.php | 5 +- tests/APIs/CourseAdminApiTest.php | 131 ++++++++++++++---- tests/APIs/CourseTutorApiTest.php | 104 ++++++++++++-- 10 files changed, 220 insertions(+), 41 deletions(-) diff --git a/src/Http/Requests/CreateCourseAPIRequest.php b/src/Http/Requests/CreateCourseAPIRequest.php index ef6e80e5..a11cdc64 100644 --- a/src/Http/Requests/CreateCourseAPIRequest.php +++ b/src/Http/Requests/CreateCourseAPIRequest.php @@ -4,6 +4,7 @@ use EscolaLms\Courses\Models\Course; use EscolaLms\Courses\Rules\ValidAuthor; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Foundation\Http\FormRequest; class CreateCourseAPIRequest extends FormRequest @@ -28,7 +29,7 @@ public function rules(): array { $rules = array_merge(Course::rules(), [ 'title' => ['required', 'string', "min:3"], - ]); + ], ModelFields::getFieldsMetadataRules(Course::class)); $rules['authors.*'][] = new ValidAuthor(); return $rules; } diff --git a/src/Http/Requests/UpdateCourseAPIRequest.php b/src/Http/Requests/UpdateCourseAPIRequest.php index dbbbf7c8..bf45a418 100644 --- a/src/Http/Requests/UpdateCourseAPIRequest.php +++ b/src/Http/Requests/UpdateCourseAPIRequest.php @@ -5,6 +5,7 @@ use EscolaLms\Courses\Models\Course; use EscolaLms\Courses\Rules\ValidAuthor; use EscolaLms\Files\Rules\FileOrStringRule; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Foundation\Http\FormRequest; class UpdateCourseAPIRequest extends FormRequest @@ -36,6 +37,6 @@ public function rules() 'image' => [new FileOrStringRule(['image'], $prefixPath)], 'video' => [new FileOrStringRule(['mimes:mp4,ogg,webm'], $prefixPath)], 'poster' => [new FileOrStringRule(['image'], $prefixPath)], - ]); + ], ModelFields::getFieldsMetadataRules(Course::class)); } } diff --git a/src/Http/Resources/Admin/CourseWithProgramAdminResource.php b/src/Http/Resources/Admin/CourseWithProgramAdminResource.php index 490a180a..ddbcc203 100644 --- a/src/Http/Resources/Admin/CourseWithProgramAdminResource.php +++ b/src/Http/Resources/Admin/CourseWithProgramAdminResource.php @@ -6,6 +6,8 @@ use EscolaLms\Courses\Http\Resources\ScormScoResource; use EscolaLms\Courses\Http\Resources\TutorResource; use EscolaLms\Courses\Models\Course; +use EscolaLms\ModelFields\Enum\MetaFieldVisibilityEnum; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Http\Resources\Json\JsonResource; class CourseWithProgramAdminResource extends JsonResource @@ -61,6 +63,7 @@ public function toArray($request): array 'target_group' => $course->target_group, 'teaser_url' => $course->teaser_url, 'public' => $course->public, + ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC), ]; return self::apply($fields, $this); diff --git a/src/Http/Resources/CourseListResource.php b/src/Http/Resources/CourseListResource.php index bbe66d03..1ad966be 100644 --- a/src/Http/Resources/CourseListResource.php +++ b/src/Http/Resources/CourseListResource.php @@ -3,6 +3,8 @@ namespace EscolaLms\Courses\Http\Resources; use EscolaLms\Auth\Traits\ResourceExtandable; +use EscolaLms\ModelFields\Enum\MetaFieldVisibilityEnum; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Http\Resources\Json\JsonResource; class CourseListResource extends JsonResource @@ -43,6 +45,7 @@ public function toArray($request) 'poster_url' => $this->poster_url, 'teaser_url' => $this->teaser_url, 'public' => $this->public ?? false, + ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC), ]; return self::apply($fields, $this); diff --git a/src/Http/Resources/CourseResource.php b/src/Http/Resources/CourseResource.php index 236fea06..ea7e7ce7 100644 --- a/src/Http/Resources/CourseResource.php +++ b/src/Http/Resources/CourseResource.php @@ -4,6 +4,8 @@ use EscolaLms\Courses\Models\Course; use EscolaLms\Courses\ValueObjects\CourseContent; +use EscolaLms\ModelFields\Enum\MetaFieldVisibilityEnum; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Http\Resources\Json\JsonResource; class CourseResource extends JsonResource @@ -50,6 +52,7 @@ public function toArray($request) 'image_url' => $course->image_url, 'video_url' => $course->video_url, 'poster_url' => $course->poster_url, + ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC), ]; } } diff --git a/src/Http/Resources/CourseSimpleResource.php b/src/Http/Resources/CourseSimpleResource.php index 50dcdfe4..892c6961 100644 --- a/src/Http/Resources/CourseSimpleResource.php +++ b/src/Http/Resources/CourseSimpleResource.php @@ -3,6 +3,8 @@ namespace EscolaLms\Courses\Http\Resources; use EscolaLms\Auth\Traits\ResourceExtandable; +use EscolaLms\ModelFields\Enum\MetaFieldVisibilityEnum; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Http\Resources\Json\JsonResource; class CourseSimpleResource extends JsonResource @@ -44,6 +46,7 @@ public function toArray($request) 'poster_url' => $this->poster_url, 'teaser_url' => $this->teaser_url, 'public' => $this->public ?? false, + ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC), ]; return self::apply($fields, $this); } diff --git a/src/Http/Resources/CourseWithProgramResource.php b/src/Http/Resources/CourseWithProgramResource.php index a1080a26..6903e15f 100644 --- a/src/Http/Resources/CourseWithProgramResource.php +++ b/src/Http/Resources/CourseWithProgramResource.php @@ -5,6 +5,8 @@ use EscolaLms\Courses\Models\Course; use EscolaLms\Courses\Models\Lesson; use EscolaLms\Courses\ValueObjects\CourseProgressCollection; +use EscolaLms\ModelFields\Enum\MetaFieldVisibilityEnum; +use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Http\Resources\Json\JsonResource; class CourseWithProgramResource extends JsonResource @@ -58,6 +60,7 @@ public function toArray($request): array 'target_group' => $course->target_group, 'teaser_url' => $course->teaser_url, 'public' => $this->public ?? false, + ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC), ]; } } diff --git a/src/Models/Course.php b/src/Models/Course.php index fd18167d..9e26eeb9 100644 --- a/src/Models/Course.php +++ b/src/Models/Course.php @@ -9,6 +9,7 @@ use EscolaLms\Courses\Enum\CourseStatusEnum; use EscolaLms\Courses\Enum\PlatformVisibility; use EscolaLms\Courses\Events\CourseStatusChanged; +use EscolaLms\ModelFields\Traits\ModelFields; use EscolaLms\Tags\Models\Tag; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -166,7 +167,9 @@ class Course extends Model { - use HasFactory, QueryCacheable; + use HasFactory; + use QueryCacheable; + use ModelFields; public $table = 'courses'; diff --git a/tests/APIs/CourseAdminApiTest.php b/tests/APIs/CourseAdminApiTest.php index 023c7c54..5bc59454 100644 --- a/tests/APIs/CourseAdminApiTest.php +++ b/tests/APIs/CourseAdminApiTest.php @@ -12,6 +12,7 @@ use EscolaLms\Courses\Models\Lesson; use EscolaLms\Courses\Models\Topic; use EscolaLms\Courses\Tests\TestCase; +use EscolaLms\ModelFields\Facades\ModelFields; use EscolaLms\Tags\Models\Tag; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Http\UploadedFile; @@ -36,7 +37,7 @@ protected function setUp(): void $this->user->assignRole('admin'); } - public function test_create_course() + public function test_create_course(): void { $course = Course::factory()->make()->toArray(); @@ -53,7 +54,34 @@ public function test_create_course() $this->assertApiResponse($course); } - public function test_create_course_published() + public function test_create_course_with_additional_model_fields(): void + { + ModelFields::addOrUpdateMetadataField( + Course::class, + 'extra_field', + 'text', + '', + ['required', 'string', 'max:255'] + ); + + $course = Course::factory()->make()->toArray(); + + $this->response = $this->actingAs($this->user, 'api')->json( + 'POST', + '/api/admin/courses', + array_merge($course, ['extra_field' => 'value']), + ); + + $course['author_id'] = $this->user->id; + + $this->response + ->assertStatus(201) + ->assertJsonFragment(['extra_field' => 'value']); + + $this->assertApiResponse($course); + } + + public function test_create_course_published(): void { Event::fake(); $course = Course::factory([ @@ -74,7 +102,7 @@ public function test_create_course_published() Event::assertDispatched(CoursedPublished::class); } - public function test_create_and_update_course_with_deadline() + public function test_create_and_update_course_with_deadline(): void { $course = Course::factory()->make([ 'status' => CourseStatusEnum::PUBLISHED, @@ -113,7 +141,7 @@ public function test_create_and_update_course_with_deadline() /** * @test */ - public function test_read_course() + public function test_read_course(): void { $course = Course::factory()->create(); @@ -128,7 +156,33 @@ public function test_read_course() /** * @test */ - public function test_update_course() + public function test_read_course_with_model_fields(): void + { + ModelFields::addOrUpdateMetadataField( + Course::class, + 'extra_field', + 'text', + '', + ['required', 'string', 'max:255'] + ); + + $course = Course::factory()->create([ + 'extra_field' => 'value', + ]); + + $this->response = $this->actingAs($this->user, 'api')->json( + 'GET', + '/api/admin/courses/' . $course->id + ) + ->assertJsonFragment(['extra_field' => 'value']); + + $this->assertApiResponse($course->toArray()); + } + + /** + * @test + */ + public function test_update_course(): void { $course = Course::factory()->create(); $editedCourse = Course::factory()->make()->toArray(); @@ -142,7 +196,34 @@ public function test_update_course() $this->assertApiResponse($editedCourse); } - public function test_active_course() + /** + * @test + */ + public function test_update_course_with_model_fields(): void + { + ModelFields::addOrUpdateMetadataField( + Course::class, + 'extra_field', + 'text', + '', + ['required', 'string', 'max:255'] + ); + + $course = Course::factory()->create([ + 'extra_field' => 'value', + ]); + + $this->response = $this->actingAs($this->user, 'api')->json( + 'PUT', + '/api/admin/courses/' . $course->id, + [ + 'extra_field' => 'update value' + ] + ) + ->assertJsonFragment(['extra_field' => 'updated value']); + } + + public function test_active_course(): void { Event::fake(); $course = Course::factory([ @@ -165,7 +246,7 @@ public function test_active_course() /** * @test */ - public function test_update_course_with_correct_author() + public function test_update_course_with_correct_author(): void { $course = Course::factory()->create(); $editedCourse = Course::factory()->make()->toArray(); @@ -186,7 +267,7 @@ public function test_update_course_with_correct_author() /** * @test */ - public function test_update_course_with_wrong_author() + public function test_update_course_with_wrong_author(): void { $course = Course::factory()->create(); $editedCourse = Course::factory()->make()->toArray(); @@ -204,7 +285,7 @@ public function test_update_course_with_wrong_author() $this->response->assertInvalid('authors.0'); } - public function test_update_course_remove_authors() + public function test_update_course_remove_authors(): void { $course = Course::factory()->create([ 'author_id' => $this->user->getKey() @@ -230,7 +311,7 @@ public function test_update_course_remove_authors() /** * @test */ - public function test_delete_course() + public function test_delete_course(): void { $course = Course::factory()->create(); @@ -248,7 +329,7 @@ public function test_delete_course() $this->response->assertStatus(404); } - public function test_category_course() + public function test_category_course(): void { $category = Category::factory()->create(); $category2 = Category::factory()->create(); @@ -277,7 +358,7 @@ public function test_category_course() } } - public function test_categories_course() + public function test_categories_course(): void { $category = Category::factory()->create(); $category2 = Category::factory()->create(); @@ -310,7 +391,7 @@ public function test_categories_course() } } - public function test_categories_and_category_course_unprocessable() + public function test_categories_and_category_course_unprocessable(): void { $category = Category::factory()->create(); $category2 = Category::factory()->create(); @@ -330,7 +411,7 @@ public function test_categories_and_category_course_unprocessable() )->assertUnprocessable(); } - public function test_attach_categories_course() + public function test_attach_categories_course(): void { $course = Course::factory()->create(); $categoriesIds = Category::factory(5)->create()->pluck('id')->toArray(); @@ -353,7 +434,7 @@ public function test_attach_categories_course() } } - public function test_attach_tags_course() + public function test_attach_tags_course(): void { $course = Course::factory()->create(); @@ -372,7 +453,7 @@ public function test_attach_tags_course() } } - public function test_search_course_by_tag() + public function test_search_course_by_tag(): void { $course = Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED, 'findable' => true]); $course2 = Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED, 'findable' => true]); @@ -464,7 +545,7 @@ public function test_search_course_by_tag() /** * @test */ - public function test_read_course_program() + public function test_read_course_program(): void { $course = Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED]); @@ -488,7 +569,7 @@ public function test_read_course_program() /** * @test */ - public function test_read_course_program_topics_count() + public function test_read_course_program_topics_count(): void { $course = Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED]); $lesson = Lesson::factory()->create(['course_id' => $course->id]); @@ -509,7 +590,7 @@ public function test_read_course_program_topics_count() /** * @test */ - public function test_read_course_program_scorm() + public function test_read_course_program_scorm(): void { $course = Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED]); @@ -521,7 +602,7 @@ public function test_read_course_program_scorm() $this->response->assertStatus(200); } - public function test_public_endpoint_displays_draft_and_archived_for_admins() + public function test_public_endpoint_displays_draft_and_archived_for_admins(): void { Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED]); Course::factory()->create(['status' => CourseStatusEnum::DRAFT]); @@ -544,7 +625,7 @@ public function test_public_endpoint_displays_draft_and_archived_for_admins() $this->response->assertJsonCount(3, 'data'); } - public function test_admin_status_search() + public function test_admin_status_search(): void { Course::factory()->create(['status' => CourseStatusEnum::PUBLISHED]); Course::factory()->create(['status' => CourseStatusEnum::DRAFT]); @@ -594,7 +675,7 @@ public function test_admin_status_search() /** * @test */ - public function test_create_admin_course_poster() + public function test_create_admin_course_poster(): void { Storage::fake('local'); $poster = UploadedFile::fake()->image('poster.jpg'); @@ -618,7 +699,7 @@ public function test_create_admin_course_poster() ]); } - public function test_delete_admin_course_poster() + public function test_delete_admin_course_poster(): void { Storage::fake('local'); $poster = UploadedFile::fake()->image('poster.jpg'); @@ -654,7 +735,7 @@ public function test_delete_admin_course_poster() /** * @test */ - public function test_update_admin_course_poster() + public function test_update_admin_course_poster(): void { Storage::fake('local'); $course = Course::factory()->create(); @@ -678,7 +759,7 @@ public function test_update_admin_course_poster() ]); } - public function test_update_admin_course_image() + public function test_update_admin_course_image(): void { Storage::fake(); $course = Course::factory()->create(); diff --git a/tests/APIs/CourseTutorApiTest.php b/tests/APIs/CourseTutorApiTest.php index bfc1cafc..01a88245 100644 --- a/tests/APIs/CourseTutorApiTest.php +++ b/tests/APIs/CourseTutorApiTest.php @@ -33,7 +33,7 @@ protected function setUp(): void $this->user->assignRole('tutor'); } - public function test_create_course() + public function test_create_course(): void { $course = Course::factory()->make([ 'status' => CourseStatusEnum::PUBLISHED @@ -79,11 +79,40 @@ public function test_create_course() $this->assertTrue($this->response->getData()->data->id === $userId); } + public function test_create_course_with_additional_model_fields(): void + { + ModelFields::addOrUpdateMetadataField( + Course::class, + 'extra_field', + 'text', + '', + ['required', 'string', 'max:255'] + ); + + $course = Course::factory()->make([ + 'status' => CourseStatusEnum::PUBLISHED, + ])->toArray(); + + $this->response = $this->actingAs($this->user, 'api')->json( + 'POST', + '/api/admin/courses', + array_merge($course, ['extra_field' => 'value']), + ); + + $course['author_id'] = $this->user->id; + + $this->response + ->assertStatus(201) + ->assertJsonFragment(['extra_field' => 'value']); + + $this->assertApiResponse($course); + } + /** * @test */ - public function test_read_course() + public function test_read_course(): void { $course = Course::factory()->create([ 'status' => CourseStatusEnum::PUBLISHED, @@ -97,7 +126,31 @@ public function test_read_course() $this->assertApiResponse($course->toArray()); } - public function test_read_owned_inactive_course() + public function test_read_course_with_model_fields(): void + { + ModelFields::addOrUpdateMetadataField( + Course::class, + 'extra_field', + 'text', + '', + ['required', 'string', 'max:255'] + ); + + $course = Course::factory()->create([ + 'status' => CourseStatusEnum::PUBLISHED, + 'extra_field' => 'value', + ]); + + $this->response = $this->actingAs($this->user, 'api')->json( + 'GET', + '/api/admin/courses/' . $course->id + ) + ->assertJsonFragment(['extra_field' => 'value']); + + $this->assertApiResponse($course->toArray()); + } + + public function test_read_owned_inactive_course(): void { $course = Course::factory()->create([ 'status' => CourseStatusEnum::ARCHIVED, @@ -115,7 +168,7 @@ public function test_read_owned_inactive_course() /** * @test */ - public function test_update_course() + public function test_update_course(): void { $course = Course::factory()->create([ 'author_id' => $this->user->id @@ -132,10 +185,35 @@ public function test_update_course() $this->assertApiResponse($editedCourse); } + public function test_update_course_with_model_fields(): void + { + ModelFields::addOrUpdateMetadataField( + Course::class, + 'extra_field', + 'text', + '', + ['required', 'string', 'max:255'] + ); + + $course = Course::factory()->create([ + 'status' => CourseStatusEnum::PUBLISHED, + 'extra_field' => 'value', + ]); + + $this->response = $this->actingAs($this->user, 'api')->json( + 'PUT', + '/api/admin/courses/' . $course->id, + [ + 'extra_field' => 'update value' + ] + ) + ->assertJsonFragment(['extra_field' => 'updated value']); + } + /** * @test */ - public function test_delete_course() + public function test_delete_course(): void { $course = Course::factory()->create([ 'author_id' => $this->user->id @@ -156,7 +234,7 @@ public function test_delete_course() $this->response->assertStatus(404); } - public function test_category_course() + public function test_category_course(): void { $category = Category::factory()->create(); $category2 = Category::factory()->create(); @@ -182,7 +260,7 @@ public function test_category_course() } } - public function test_categories_course() + public function test_categories_course(): void { $category = Category::factory()->create(); $category2 = Category::factory()->create(); @@ -213,7 +291,7 @@ public function test_categories_course() } } - public function test_categories_and_category_course_unprocessable() + public function test_categories_and_category_course_unprocessable(): void { $category = Category::factory()->create(); $category2 = Category::factory()->create(); @@ -236,7 +314,7 @@ public function test_categories_and_category_course_unprocessable() /** * @test */ - public function test_read_course_program() + public function test_read_course_program(): void { $course = Course::factory()->create([ 'author_id' => $this->user->id @@ -250,7 +328,7 @@ public function test_read_course_program() $this->response->assertStatus(200); } - public function test_assign_tutor() + public function test_assign_tutor(): void { $admin = $this->makeAdmin(); @@ -270,7 +348,7 @@ public function test_assign_tutor() $this->assertTrue($course->hasAuthor($this->user)); } - public function test_unassign_tutor() + public function test_unassign_tutor(): void { $admin = $this->makeAdmin(); @@ -290,7 +368,7 @@ public function test_unassign_tutor() $this->assertFalse($course->hasAuthor($this->user)); } - public function test_update_course_status() + public function test_update_course_status(): void { Event::fake([CourseStatusChanged::class]); @@ -367,7 +445,7 @@ public function test_read_tutor_additional_field(): void ]); } - public function test_list_only_author_courses() + public function test_list_only_author_courses(): void { $admin = $this->makeAdmin(); From 59871f42f052ba378e68fb3af9f6968146b20f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Tue, 12 Mar 2024 13:16:13 +0100 Subject: [PATCH 2/3] fix tests --- tests/APIs/CourseAdminApiTest.php | 2 +- tests/APIs/CourseTutorApiTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/APIs/CourseAdminApiTest.php b/tests/APIs/CourseAdminApiTest.php index 5bc59454..a82c01fe 100644 --- a/tests/APIs/CourseAdminApiTest.php +++ b/tests/APIs/CourseAdminApiTest.php @@ -217,7 +217,7 @@ public function test_update_course_with_model_fields(): void 'PUT', '/api/admin/courses/' . $course->id, [ - 'extra_field' => 'update value' + 'extra_field' => 'updated value' ] ) ->assertJsonFragment(['extra_field' => 'updated value']); diff --git a/tests/APIs/CourseTutorApiTest.php b/tests/APIs/CourseTutorApiTest.php index 01a88245..4f36e7ee 100644 --- a/tests/APIs/CourseTutorApiTest.php +++ b/tests/APIs/CourseTutorApiTest.php @@ -204,7 +204,7 @@ public function test_update_course_with_model_fields(): void 'PUT', '/api/admin/courses/' . $course->id, [ - 'extra_field' => 'update value' + 'extra_field' => 'updated value' ] ) ->assertJsonFragment(['extra_field' => 'updated value']); From 81e347b700e02466bf69d1d5bb69629f179f7e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 13 Mar 2024 09:15:30 +0100 Subject: [PATCH 3/3] fix tests --- src/Http/Resources/CourseResource.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Http/Resources/CourseResource.php b/src/Http/Resources/CourseResource.php index ea7e7ce7..236fea06 100644 --- a/src/Http/Resources/CourseResource.php +++ b/src/Http/Resources/CourseResource.php @@ -4,8 +4,6 @@ use EscolaLms\Courses\Models\Course; use EscolaLms\Courses\ValueObjects\CourseContent; -use EscolaLms\ModelFields\Enum\MetaFieldVisibilityEnum; -use EscolaLms\ModelFields\Facades\ModelFields; use Illuminate\Http\Resources\Json\JsonResource; class CourseResource extends JsonResource @@ -52,7 +50,6 @@ public function toArray($request) 'image_url' => $course->image_url, 'video_url' => $course->video_url, 'poster_url' => $course->poster_url, - ...ModelFields::getExtraAttributesValues($this->resource, MetaFieldVisibilityEnum::PUBLIC), ]; } }