diff --git a/app/Filament/Resources/Manage/Cooperations/CooperationResource.php b/app/Filament/Resources/Manage/Cooperations/CooperationResource.php index 2d3cf17..d927588 100644 --- a/app/Filament/Resources/Manage/Cooperations/CooperationResource.php +++ b/app/Filament/Resources/Manage/Cooperations/CooperationResource.php @@ -139,11 +139,11 @@ public static function infolist(Schema $schema): Schema ImageEntry::make('banner') ->label('Banner') - ->getStateUsing(fn (Cooperation $record): ?string => optional($record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->sortByDesc('created_at')->first())->getPathRelativeToRoot()) + ->getStateUsing(fn (Cooperation $record): ?string => optional($record->getMedia('banner')->sortByDesc('created_at')->first() ?? $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->sortByDesc('created_at')->first())->getPathRelativeToRoot()) ->disk(config('filesystems.default')) - ->visible(fn (Cooperation $record): bool => $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty()), + ->visible(fn (Cooperation $record): bool => $record->getMedia('banner')->isNotEmpty() || $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty()), ]) - ->visible(fn (Cooperation $record): bool => $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty() && $record->getMedia('cooperations')->where('custom_properties.doc_type', 'proposal-template')->isNotEmpty()), + ->visible(fn (Cooperation $record): bool => $record->getMedia('banner')->isNotEmpty() || $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty() || $record->getMedia('cooperations')->where('custom_properties.doc_type', 'proposal-template')->isNotEmpty()), TextEntry::make('description') ->label('Deskripsi'), diff --git a/app/Filament/Resources/Manage/Cooperations/Schemas/CooperationForm.php b/app/Filament/Resources/Manage/Cooperations/Schemas/CooperationForm.php index 155b0fb..b3fd435 100644 --- a/app/Filament/Resources/Manage/Cooperations/Schemas/CooperationForm.php +++ b/app/Filament/Resources/Manage/Cooperations/Schemas/CooperationForm.php @@ -90,7 +90,7 @@ public static function configure(Schema $schema): Schema ->disk(config('filesystems.default')) ->acceptedFileTypes(['image/*']) ->maxSize(1024 * 3) - ->collection('cooperations') + ->collection('banner') ->customProperties(fn (): array => [ 'feature' => 'cooperations', 'doc_type' => 'banner', diff --git a/app/Filament/Resources/Publication/Announcements/AnnouncementResource.php b/app/Filament/Resources/Publication/Announcements/AnnouncementResource.php index 32a1996..68a83bb 100644 --- a/app/Filament/Resources/Publication/Announcements/AnnouncementResource.php +++ b/app/Filament/Resources/Publication/Announcements/AnnouncementResource.php @@ -139,7 +139,7 @@ public static function table(Table $table): Table ]) ->recordActions([ EditAction::make() - ->modalWidth(Width::TwoExtraLarge) + ->modalWidth(Width::FiveExtraLarge) ->visible(fn (Announcement $record): bool => $record->type === AnnouncementType::PUBLIC), DeleteAction::make(), diff --git a/app/Filament/Resources/Publication/Announcements/Pages/ManageAnnouncements.php b/app/Filament/Resources/Publication/Announcements/Pages/ManageAnnouncements.php index 1c6888e..7e91860 100644 --- a/app/Filament/Resources/Publication/Announcements/Pages/ManageAnnouncements.php +++ b/app/Filament/Resources/Publication/Announcements/Pages/ManageAnnouncements.php @@ -30,7 +30,7 @@ protected function getHeaderActions(): array $action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) ->label('Simpan dan Tambah Lagi'), ]) - ->modalWidth(Width::TwoExtraLarge) + ->modalWidth(Width::FiveExtraLarge) ->after(function (array $data) { if ($data['type'] === AnnouncementType::PUBLIC) { return; diff --git a/app/Models/AnnouncementMedia.php b/app/Models/AnnouncementMedia.php index 6587216..9c7804e 100644 --- a/app/Models/AnnouncementMedia.php +++ b/app/Models/AnnouncementMedia.php @@ -13,6 +13,14 @@ class AnnouncementMedia extends Model protected $guarded = ['id']; + protected function casts(): array + { + return [ + 'announcement_id' => 'integer', + 'partner_media_id' => 'integer', + ]; + } + public function announcement(): BelongsTo { return $this->belongsTo(Announcement::class); diff --git a/app/Models/Classification.php b/app/Models/Classification.php index 84ba19a..2e247fc 100644 --- a/app/Models/Classification.php +++ b/app/Models/Classification.php @@ -37,11 +37,6 @@ protected function inactive(Builder $query): void $query->where('is_active', IsActive::INACTIVE); } - public function subClassifications(): HasMany - { - return $this->hasMany(SubClassification::class); - } - public function contentRecaps(): HasMany { return $this->hasMany(ContentRecap::class); @@ -51,4 +46,9 @@ public function issueManagements(): HasMany { return $this->hasMany(IssueManagement::class); } + + public function subClassifications(): HasMany + { + return $this->hasMany(SubClassification::class); + } } diff --git a/app/Models/Company.php b/app/Models/Company.php index e95a2da..789924a 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -18,6 +18,13 @@ class Company extends Model implements HasMedia protected $guarded = ['id']; + protected function casts(): array + { + return [ + 'user_id' => 'integer', + ]; + } + public function journalists(): HasManyThrough { return $this->hasManyThrough(Journalist::class, PartnerMedia::class); diff --git a/app/Models/Contact.php b/app/Models/Contact.php index b838bad..1427ccf 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -12,6 +12,14 @@ class Contact extends Model protected $guarded = ['id']; + protected function casts(): array + { + return [ + 'replied_at' => 'datetime', + 'replied_by' => 'integer', + ]; + } + public function repliedBy(): BelongsTo { return $this->belongsTo(User::class, 'replied_by'); diff --git a/app/Models/ContentRecap.php b/app/Models/ContentRecap.php index 283a9e3..804371c 100644 --- a/app/Models/ContentRecap.php +++ b/app/Models/ContentRecap.php @@ -22,6 +22,7 @@ protected function casts(): array return [ 'type' => ContentType::class, 'posting_date' => 'date', + 'classification_id' => 'integer', ]; } diff --git a/app/Models/Cooperation.php b/app/Models/Cooperation.php index 0231284..8585c04 100644 --- a/app/Models/Cooperation.php +++ b/app/Models/Cooperation.php @@ -77,6 +77,16 @@ public function partnerMedia(): BelongsToMany ->withTimestamps(); } + public function payments(): HasManyThrough + { + return $this->hasManyThrough( + CooperationPayment::class, + CooperationMedia::class, + 'cooperation_id', + 'cooperation_media_id' + ); + } + public function proposal(): HasMany { return $this->hasMany(CooperationProposal::class); @@ -96,14 +106,4 @@ public function taskAssignment(): HasOne { return $this->hasOne(TaskAssignment::class); } - - public function payments(): HasManyThrough - { - return $this->hasManyThrough( - CooperationPayment::class, - CooperationMedia::class, - 'cooperation_id', - 'cooperation_media_id' - ); - } } diff --git a/app/Models/CooperationMedia.php b/app/Models/CooperationMedia.php index abf35fb..8465531 100644 --- a/app/Models/CooperationMedia.php +++ b/app/Models/CooperationMedia.php @@ -26,6 +26,8 @@ protected function casts(): array { return [ 'status' => ApprovalStatus::class, + 'cooperation_id' => 'integer', + 'partner_media_id' => 'integer', ]; } diff --git a/app/Models/CooperationPayment.php b/app/Models/CooperationPayment.php index 467abef..3e02c49 100644 --- a/app/Models/CooperationPayment.php +++ b/app/Models/CooperationPayment.php @@ -20,6 +20,7 @@ protected function casts(): array return [ 'amount' => 'integer', 'payment_date' => 'date', + 'cooperation_media_id' => 'integer', ]; } diff --git a/app/Models/DataChangeRequest.php b/app/Models/DataChangeRequest.php index a82728c..f414492 100644 --- a/app/Models/DataChangeRequest.php +++ b/app/Models/DataChangeRequest.php @@ -24,6 +24,8 @@ protected function casts(): array 'status' => DataChangeStatus::class, 'old_data' => 'array', 'new_data' => 'array', + 'user_id' => 'integer', + 'entity_id' => 'integer', ]; } @@ -45,9 +47,9 @@ protected function rejected(Builder $query): void $query->where('status', DataChangeStatus::REJECTED); } - public function user(): BelongsTo + public function entity(): MorphTo { - return $this->belongsTo(User::class); + return $this->morphTo(); } public function review(): HasOne @@ -55,8 +57,8 @@ public function review(): HasOne return $this->hasOne(DataChangeReview::class); } - public function entity(): MorphTo + public function user(): BelongsTo { - return $this->morphTo(); + return $this->belongsTo(User::class); } } diff --git a/app/Models/DataChangeReview.php b/app/Models/DataChangeReview.php index 6dbb6d6..f6f849c 100644 --- a/app/Models/DataChangeReview.php +++ b/app/Models/DataChangeReview.php @@ -17,6 +17,8 @@ protected function casts(): array { return [ 'decision' => DataChangeDecision::class, + 'data_change_request_id' => 'integer', + 'reviewer_id' => 'integer', ]; } diff --git a/app/Models/IssueManagement.php b/app/Models/IssueManagement.php index 09dfeff..0e9da66 100644 --- a/app/Models/IssueManagement.php +++ b/app/Models/IssueManagement.php @@ -20,31 +20,36 @@ protected function casts(): array return [ 'issue' => IssueSentiment::class, 'response' => IssueSentiment::class, + 'location_id' => 'integer', + 'sub_location_id' => 'integer', + 'classification_id' => 'integer', + 'sub_classification_id' => 'integer', + 'media_monitoring_id' => 'integer', ]; } - public function location(): BelongsTo - { - return $this->belongsTo(Location::class); - } - - public function subLocation(): BelongsTo - { - return $this->belongsTo(SubLocation::class); - } - public function classification(): BelongsTo { return $this->belongsTo(Classification::class); } - public function subClassification(): BelongsTo + public function location(): BelongsTo { - return $this->belongsTo(SubClassification::class); + return $this->belongsTo(Location::class); } public function mediaMonitoring(): BelongsTo { return $this->belongsTo(MediaMonitoring::class); } + + public function subClassification(): BelongsTo + { + return $this->belongsTo(SubClassification::class); + } + + public function subLocation(): BelongsTo + { + return $this->belongsTo(SubLocation::class); + } } diff --git a/app/Models/Journalist.php b/app/Models/Journalist.php index cbbc11d..a5e5b74 100644 --- a/app/Models/Journalist.php +++ b/app/Models/Journalist.php @@ -17,6 +17,13 @@ class Journalist extends Model implements HasMedia protected $guarded = ['id']; + protected function casts(): array + { + return [ + 'partner_media_id' => 'integer', + ]; + } + public function partnerMedia(): BelongsTo { return $this->belongsTo(PartnerMedia::class); diff --git a/app/Models/MediaMonitoringTheme.php b/app/Models/MediaMonitoringTheme.php index 39858ae..92d5c17 100644 --- a/app/Models/MediaMonitoringTheme.php +++ b/app/Models/MediaMonitoringTheme.php @@ -15,6 +15,14 @@ class MediaMonitoringTheme extends Model protected $guarded = ['id']; + protected function casts(): array + { + return [ + 'media_monitoring_id' => 'integer', + 'theme_id' => 'integer', + ]; + } + public function mediaMonitoring(): BelongsTo { return $this->belongsTo(MediaMonitoring::class); diff --git a/app/Models/MediaTaskAssignment.php b/app/Models/MediaTaskAssignment.php index a9aefb9..5eb8d88 100644 --- a/app/Models/MediaTaskAssignment.php +++ b/app/Models/MediaTaskAssignment.php @@ -22,14 +22,11 @@ protected function casts(): array { return [ 'status' => ApprovalStatus::class, + 'task_assignment_id' => 'integer', + 'partner_media_id' => 'integer', ]; } - public function taskAssignment(): BelongsTo - { - return $this->belongsTo(TaskAssignment::class); - } - public function partnerMedia(): BelongsTo { return $this->belongsTo(PartnerMedia::class); @@ -44,4 +41,9 @@ public function reports(): HasMany { return $this->hasMany(Report::class); } + + public function taskAssignment(): BelongsTo + { + return $this->belongsTo(TaskAssignment::class); + } } diff --git a/app/Models/News.php b/app/Models/News.php index 6ca4702..123d7bf 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -26,9 +26,10 @@ class News extends Model implements HasMedia protected function casts(): array { return [ - 'views' => 'int', + 'views' => 'integer', 'status' => NewsStatus::class, 'published_at' => 'datetime', + 'author_id' => 'integer', ]; } diff --git a/app/Models/PartnerMedia.php b/app/Models/PartnerMedia.php index 0e07e91..d830db2 100644 --- a/app/Models/PartnerMedia.php +++ b/app/Models/PartnerMedia.php @@ -28,6 +28,7 @@ protected function casts(): array return [ 'type' => MediaType::class, 'classification' => MediaClassification::class, + 'company_id' => 'integer', ]; } diff --git a/app/Models/RejectionReason.php b/app/Models/RejectionReason.php index 129988d..5711c3a 100644 --- a/app/Models/RejectionReason.php +++ b/app/Models/RejectionReason.php @@ -13,6 +13,13 @@ class RejectionReason extends Model protected $guarded = ['id']; + protected function casts(): array + { + return [ + 'rejectable_id' => 'integer', + ]; + } + public function rejectable(): MorphTo { return $this->morphTo(); diff --git a/app/Models/Report.php b/app/Models/Report.php index a44d1b7..82596b3 100644 --- a/app/Models/Report.php +++ b/app/Models/Report.php @@ -23,6 +23,7 @@ protected function casts(): array return [ 'publication_date' => 'date', 'status' => ApprovalStatus::class, + 'media_task_assignment_id' => 'integer', ]; } diff --git a/app/Models/SubClassification.php b/app/Models/SubClassification.php index 747eb5c..a4460bd 100644 --- a/app/Models/SubClassification.php +++ b/app/Models/SubClassification.php @@ -23,6 +23,7 @@ protected function casts(): array return [ 'is_active' => IsActive::class, 'sort_order' => 'integer', + 'classification_id' => 'integer', ]; } diff --git a/app/Models/SubLocation.php b/app/Models/SubLocation.php index 49a3b85..137e038 100644 --- a/app/Models/SubLocation.php +++ b/app/Models/SubLocation.php @@ -23,6 +23,7 @@ protected function casts(): array return [ 'is_active' => IsActive::class, 'sort_order' => 'integer', + 'location_id' => 'integer', ]; } diff --git a/app/Models/TaskAssignment.php b/app/Models/TaskAssignment.php index acfd977..60b9e2d 100644 --- a/app/Models/TaskAssignment.php +++ b/app/Models/TaskAssignment.php @@ -22,6 +22,8 @@ protected function casts(): array return [ 'start_date' => 'date', 'end_date' => 'date', + 'report_amount' => 'integer', + 'cooperation_id' => 'integer', ]; } @@ -30,23 +32,6 @@ public function cooperation(): BelongsTo return $this->belongsTo(Cooperation::class); } - public function reports(): HasManyThrough - { - return $this->hasManyThrough( - Report::class, - MediaTaskAssignment::class, - 'task_assignment_id', // Foreign key di tabel media_task_assignment - 'media_task_assignment_id', // Foreign key di tabel reports - 'id', // Local key di tabel task_assignments - 'id' // Local key di tabel media_task_assignment - ); - } - - public function rejectionReasons(): MorphMany - { - return $this->morphMany(RejectionReason::class, 'rejectable'); - } - public function mediaTaskAssignments(): HasMany { return $this->hasMany(MediaTaskAssignment::class); @@ -59,4 +44,21 @@ public function partnerMedia(): BelongsToMany ->withPivot(['status']) ->withTimestamps(); } + + public function rejectionReasons(): MorphMany + { + return $this->morphMany(RejectionReason::class, 'rejectable'); + } + + public function reports(): HasManyThrough + { + return $this->hasManyThrough( + Report::class, + MediaTaskAssignment::class, + 'task_assignment_id', + 'media_task_assignment_id', + 'id', + 'id' + ); + } } diff --git a/app/Models/User.php b/app/Models/User.php index 2274019..23f8067 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -77,6 +77,16 @@ public function contacts(): HasMany return $this->hasMany(Contact::class, 'replied_by'); } + public function dataChangeRequests(): HasMany + { + return $this->hasMany(DataChangeRequest::class); + } + + public function dataChangeReviews(): HasMany + { + return $this->hasMany(DataChangeReview::class, 'reviewer_id'); + } + public function news(): HasMany { return $this->hasMany(News::class, 'author_id'); diff --git a/app/Models/VerificationRequest.php b/app/Models/VerificationRequest.php index 5005fc7..a7753bf 100644 --- a/app/Models/VerificationRequest.php +++ b/app/Models/VerificationRequest.php @@ -21,6 +21,8 @@ protected function casts(): array { return [ 'status' => VerificationStatus::class, + 'company_id' => 'integer', + 'submitted_by' => 'integer', ]; } diff --git a/app/Models/VerificationReview.php b/app/Models/VerificationReview.php index 765f110..be829eb 100644 --- a/app/Models/VerificationReview.php +++ b/app/Models/VerificationReview.php @@ -20,6 +20,8 @@ protected function casts(): array { return [ 'decision' => DecisionAdmin::class, + 'verification_request_id' => 'integer', + 'reviewer_id' => 'integer', ]; } @@ -41,13 +43,13 @@ protected function rejected(Builder $query): void $query->where('decision', DecisionAdmin::REJECTED); } - public function verificationRequest(): BelongsTo - { - return $this->belongsTo(VerificationRequest::class); - } - public function reviewer(): BelongsTo { return $this->belongsTo(User::class, 'reviewer_id'); } + + public function verificationRequest(): BelongsTo + { + return $this->belongsTo(VerificationRequest::class); + } } diff --git a/config/database.php b/config/database.php index 53dcae0..0e6b2fd 100644 --- a/config/database.php +++ b/config/database.php @@ -63,6 +63,26 @@ ]) : [], ], + 'mysql_second' => [ + 'driver' => 'mysql', + 'url' => env('DB_SECOND_URL'), + 'host' => env('DB_SECOND_HOST', '127.0.0.1'), + 'port' => env('DB_SECOND_PORT', '3306'), + 'database' => env('DB_SECOND_DATABASE', 'laravel'), + 'username' => env('DB_SECOND_USERNAME', 'root'), + 'password' => env('DB_SECOND_PASSWORD', ''), + 'unix_socket' => env('DB_SECOND_SOCKET', ''), + 'charset' => env('DB_SECOND_CHARSET', 'utf8mb4'), + 'collation' => env('DB_SECOND_COLLATION', 'utf8mb4_unicode_ci'), + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + 'mariadb' => [ 'driver' => 'mariadb', 'url' => env('DB_URL'), diff --git a/database/factories/AnnouncementFactory.php b/database/factories/AnnouncementFactory.php deleted file mode 100644 index e2cd522..0000000 --- a/database/factories/AnnouncementFactory.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -class AnnouncementFactory extends Factory -{ - protected $model = Announcement::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'content' => $this->faker->paragraphs(2, true), - ]; - } - - /** - * Indicate that the announcement is important. - */ - public function important(): static - { - return $this->state(fn (array $attributes) => [ - 'content' => 'PENTING: '.$this->faker->sentence(10), - ]); - } - - /** - * Indicate that the announcement is informational. - */ - public function informational(): static - { - return $this->state(fn (array $attributes) => [ - 'content' => 'INFORMASI: '.$this->faker->paragraph(), - ]); - } -} diff --git a/database/factories/AnnouncementMediaFactory.php b/database/factories/AnnouncementMediaFactory.php deleted file mode 100644 index 71fe3a5..0000000 --- a/database/factories/AnnouncementMediaFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ -class AnnouncementMediaFactory extends Factory -{ - protected $model = AnnouncementMedia::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'announcement_id' => Announcement::factory(), - 'partner_media_id' => PartnerMedia::factory(), - ]; - } - - /** - * Indicate that the announcement user is for a specific announcement. - */ - public function forAnnouncement(Announcement $announcement): static - { - return $this->state(fn (array $attributes) => [ - 'announcement_id' => $announcement->id, - ]); - } - - /** - * Indicate that the announcement user is for a specific partner media. - */ - public function forPartnerMedia(PartnerMedia $partnerMedia): static - { - return $this->state(fn (array $attributes) => [ - 'partner_media_id' => $partnerMedia->id, - ]); - } -} diff --git a/database/factories/ClassificationFactory.php b/database/factories/ClassificationFactory.php deleted file mode 100644 index 032e8c1..0000000 --- a/database/factories/ClassificationFactory.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class ClassificationFactory extends Factory -{ - protected $model = Classification::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => $this->faker->words(2, true), - 'description' => $this->faker->sentence(), - 'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]), - 'sort_order' => $this->faker->numberBetween(0, 100), - ]; - } - - /** - * Indicate that the classification is active. - */ - public function active(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::ACTIVE->value, - ]); - } - - /** - * Indicate that the classification is inactive. - */ - public function inactive(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::INACTIVE->value, - ]); - } -} diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php deleted file mode 100644 index ba5bd17..0000000 --- a/database/factories/CompanyFactory.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class CompanyFactory extends Factory -{ - protected $model = Company::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'user_id' => User::factory(), - 'name' => $this->faker->company(), - 'email' => $this->faker->unique()->companyEmail(), - 'address' => $this->faker->address(), - 'director_name' => $this->faker->name(), - 'director_nik' => $this->faker->numerify('################'), - 'deed_incorporation' => $this->faker->numerify('AHU-#######.AH.##.##'), - 'trade_license' => $this->faker->numerify('###/###/SIUP/####'), - 'tax_id_number' => $this->faker->numerify('##.###.###.#-###.###'), - 'taxable_enterprise' => $this->faker->numerify('###.###.###.###'), - 'annual_tax_return' => $this->faker->numerify('SPT-####-########'), - 'domicile_certificate' => $this->faker->numerify('###/###/DOMISILI/####'), - 'profile' => $this->faker->numerify('PROFILE-####-########'), - 'profile' => $this->faker->numerify('PROFILE-####-########'), - ]; - } - - /** - * Indicate that the company is validated. - */ - public function validated(): static - { - return $this->state(fn (array $attributes) => [ - 'status' => VerificationStatus::APPROVED, - ]); - } - - /** - * Indicate that the company is rejected. - */ - public function rejected(): static - { - return $this->state(fn (array $attributes) => [ - 'status' => VerificationStatus::REJECTED, - ]); - } - - /** - * Indicate that the company is pending validation. - */ - public function pending(): static - { - return $this->state(fn (array $attributes) => [ - 'status' => VerificationStatus::PENDING, - ]); - } -} diff --git a/database/factories/ContentRecapFactory.php b/database/factories/ContentRecapFactory.php deleted file mode 100644 index ace9c04..0000000 --- a/database/factories/ContentRecapFactory.php +++ /dev/null @@ -1,110 +0,0 @@ - - */ -class ContentRecapFactory extends Factory -{ - protected $model = ContentRecap::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - $channels = [ - 'Website', - 'Facebook', - 'Instagram', - 'Twitter', - 'YouTube', - 'TikTok', - 'WhatsApp', - 'Telegram', - 'LinkedIn', - ]; - - return [ - 'classification_id' => Classification::factory(), - 'title' => $this->faker->sentence(4), - 'link' => $this->faker->optional(0.8)->url(), - 'posting_date' => $this->faker->dateTimeBetween('-6 months', 'now')->format('Y-m-d'), - 'type' => $this->faker->randomElement(ContentType::cases())->value, - 'channel' => $this->faker->randomElement($channels), - 'social_media' => $this->faker->randomElement(SocialMedia::cases())->value, - ]; - } - - /** - * Indicate that the content recap is photo type. - */ - public function photo(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => ContentType::FOTO->value, - ]); - } - - /** - * Indicate that the content recap is video type. - */ - public function video(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => ContentType::VIDEO->value, - 'channel' => $this->faker->randomElement(['YouTube', 'Instagram', 'TikTok']), - ]); - } - - /** - * Indicate that the content recap is text type. - */ - public function text(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => ContentType::TEXT->value, - ]); - } - - /** - * Indicate that the content recap is graphic type. - */ - public function graphic(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => ContentType::GRAPHIC->value, - ]); - } - - /** - * Indicate that the content recap is for Instagram. - */ - public function instagram(): static - { - return $this->state(fn (array $attributes) => [ - 'channel' => 'Instagram', - 'social_media' => 'Instagram', - ]); - } - - /** - * Indicate that the content recap is for Facebook. - */ - public function facebook(): static - { - return $this->state(fn (array $attributes) => [ - 'channel' => 'Facebook', - 'social_media' => 'Facebook', - ]); - } -} diff --git a/database/factories/DepartmentFactory.php b/database/factories/DepartmentFactory.php deleted file mode 100644 index 648ca7f..0000000 --- a/database/factories/DepartmentFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ -class DepartmentFactory extends Factory -{ - protected $model = Department::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - $name = $this->faker->randomElement([ - 'Dinas Komunikasi dan Informatika', - 'Dinas Pendidikan', - 'Dinas Kesehatan', - 'Dinas Pekerjaan Umum', - 'Dinas Sosial', - 'Dinas Pariwisata', - 'Dinas Perhubungan', - 'Dinas Lingkungan Hidup', - ]); - - return [ - 'name' => $name, - 'alias' => strtoupper(substr(str_replace(['Dinas ', ' dan ', ' '], ['', '', ''], $name), 0, 10)), - 'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]), - 'sort_order' => $this->faker->numberBetween(0, 100), - ]; - } - - /** - * Indicate that the department is active. - */ - public function active(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::ACTIVE->value, - ]); - } - - /** - * Indicate that the department is inactive. - */ - public function inactive(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::INACTIVE->value, - ]); - } -} diff --git a/database/factories/IssueManagementFactory.php b/database/factories/IssueManagementFactory.php deleted file mode 100644 index 61dba45..0000000 --- a/database/factories/IssueManagementFactory.php +++ /dev/null @@ -1,109 +0,0 @@ - - */ -class IssueManagementFactory extends Factory -{ - protected $model = IssueManagement::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'location_id' => Location::factory(), - 'sub_location_id' => SubLocation::factory(), - 'classification_id' => Classification::factory(), - 'sub_classification_id' => SubClassification::factory(), - 'media_monitoring_id' => MediaMonitoring::factory(), - 'issue' => $this->faker->randomElement(IssueSentiment::cases())->value, - 'response' => $this->faker->randomElement(IssueSentiment::cases())->value, - 'description' => $this->faker->paragraphs(2, true), - ]; - } - - /** - * Indicate that the issue is positive. - */ - public function positive(): static - { - return $this->state(fn (array $attributes) => [ - 'issue' => IssueSentiment::POSITIVE->value, - 'response' => IssueSentiment::POSITIVE->value, - ]); - } - - /** - * Indicate that the issue is negative. - */ - public function negative(): static - { - return $this->state(fn (array $attributes) => [ - 'issue' => IssueSentiment::NEGATIVE->value, - 'response' => $this->faker->randomElement([ - IssueSentiment::POSITIVE->value, - IssueSentiment::NEUTRAL->value, - ]), - ]); - } - - /** - * Indicate that the issue is neutral. - */ - public function neutral(): static - { - return $this->state(fn (array $attributes) => [ - 'issue' => IssueSentiment::NEUTRAL->value, - 'response' => IssueSentiment::NEUTRAL->value, - ]); - } - - /** - * Indicate that the issue is crisis. - */ - public function crisis(): static - { - return $this->state(fn (array $attributes) => [ - 'issue' => IssueSentiment::CRISIS->value, - 'response' => $this->faker->randomElement([ - IssueSentiment::POSITIVE->value, - IssueSentiment::NEUTRAL->value, - ]), - ]); - } - - /** - * Indicate that the issue has no sub location. - */ - public function withoutSubLocation(): static - { - return $this->state(fn (array $attributes) => [ - 'sub_location_id' => null, - ]); - } - - /** - * Indicate that the issue has no sub classification. - */ - public function withoutSubClassification(): static - { - return $this->state(fn (array $attributes) => [ - 'sub_classification_id' => null, - ]); - } -} diff --git a/database/factories/JournalistFactory.php b/database/factories/JournalistFactory.php deleted file mode 100644 index 33c8338..0000000 --- a/database/factories/JournalistFactory.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class JournalistFactory extends Factory -{ - protected $model = Journalist::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'partner_media_id' => PartnerMedia::factory(), - 'name' => $this->faker->name(), - 'email' => $this->faker->unique()->safeEmail(), - 'phone_number' => $this->faker->phoneNumber(), - 'press_card' => $this->faker->optional(0.8)->numerify('PWI-####-########'), - 'ukw_certificate' => $this->faker->optional(0.6)->numerify('UKW-####-########'), - ]; - } - - /** - * Indicate that the journalist has press credentials. - */ - public function withCredentials(): static - { - return $this->state(fn (array $attributes) => [ - 'press_card' => $this->faker->numerify('PWI-####-########'), - 'ukw_certificate' => $this->faker->numerify('UKW-####-########'), - ]); - } - - /** - * Indicate that the journalist has no credentials. - */ - public function withoutCredentials(): static - { - return $this->state(fn (array $attributes) => [ - 'press_card' => null, - 'ukw_certificate' => null, - ]); - } -} diff --git a/database/factories/LocationFactory.php b/database/factories/LocationFactory.php deleted file mode 100644 index a8e5da5..0000000 --- a/database/factories/LocationFactory.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class LocationFactory extends Factory -{ - protected $model = Location::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => $this->faker->city(), - 'description' => $this->faker->sentence(), - 'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]), - 'sort_order' => $this->faker->numberBetween(0, 100), - ]; - } - - /** - * Indicate that the location is active. - */ - public function active(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::ACTIVE->value, - ]); - } - - /** - * Indicate that the location is inactive. - */ - public function inactive(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::INACTIVE->value, - ]); - } -} diff --git a/database/factories/MediaMonitoringFactory.php b/database/factories/MediaMonitoringFactory.php deleted file mode 100644 index af55701..0000000 --- a/database/factories/MediaMonitoringFactory.php +++ /dev/null @@ -1,106 +0,0 @@ - - */ -class MediaMonitoringFactory extends Factory -{ - protected $model = MediaMonitoring::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - $mediaNames = [ - 'Kompas.com', - 'Detik.com', - 'Tribun News', - 'Liputan6', - 'CNN Indonesia', - 'ANTARA News', - 'Tempo.co', - 'Okezone', - 'Suara.com', - 'Bisnis.com', - ]; - - $channels = [ - 'Website', - 'Facebook', - 'Instagram', - 'Twitter', - 'YouTube', - 'TikTok', - 'WhatsApp', - 'Telegram', - 'LinkedIn', - ]; - - return [ - 'code' => $this->faker->unique()->regexify('[A-Z]{2}[0-9]{8}'), - 'media_name' => $this->faker->randomElement($mediaNames), - 'title' => $this->faker->sentence(6), - 'channel' => $this->faker->randomElement($channels), - 'writter' => $this->faker->name(), - 'link' => $this->faker->optional(0.8)->url(), - 'news_page' => $this->faker->optional(0.3)->numberBetween(1, 20), - 'quote' => $this->faker->optional(0.4)->paragraph(), - 'content' => $this->faker->paragraphs(3, true), - 'influencer' => $this->faker->optional(0.2)->name(), - 'keyword' => implode(', ', $this->faker->words(3)), - 'release_date' => $this->faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d'), - ]; - } - - /** - * Indicate that the media monitoring is for online media. - */ - public function online(): static - { - return $this->state(fn (array $attributes) => [ - 'channel' => $this->faker->randomElement(['Website', 'Facebook', 'Instagram', 'Twitter']), - 'link' => $this->faker->url(), - 'news_page' => null, - ]); - } - - /** - * Indicate that the media monitoring is for print media. - */ - public function print(): static - { - return $this->state(fn (array $attributes) => [ - 'channel' => 'Print', - 'link' => null, - 'news_page' => $this->faker->numberBetween(1, 20), - ]); - } - - /** - * Indicate that the media monitoring has influencer mention. - */ - public function withInfluencer(): static - { - return $this->state(fn (array $attributes) => [ - 'influencer' => $this->faker->name(), - ]); - } - - /** - * Indicate that the media monitoring has quote. - */ - public function withQuote(): static - { - return $this->state(fn (array $attributes) => [ - 'quote' => $this->faker->paragraph(), - ]); - } -} diff --git a/database/factories/MediaMonitoringThemeFactory.php b/database/factories/MediaMonitoringThemeFactory.php deleted file mode 100644 index 100c9ee..0000000 --- a/database/factories/MediaMonitoringThemeFactory.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ -class MediaMonitoringThemeFactory extends Factory -{ - protected $model = MediaMonitoringTheme::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'media_monitoring_id' => MediaMonitoring::factory(), - 'theme_id' => Theme::factory(), - ]; - } -} diff --git a/database/factories/NewsFactory.php b/database/factories/NewsFactory.php deleted file mode 100644 index c57efce..0000000 --- a/database/factories/NewsFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class NewsFactory extends Factory -{ - protected $model = News::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - $title = $this->faker->sentence(6); - - return [ - 'author_id' => User::factory(), - 'title' => $title, - 'slug' => Str::slug($title), - 'content' => $this->faker->paragraphs(3, true), - 'link' => $this->faker->optional(0.3)->url(), - 'view' => $this->faker->numberBetween(0, 10000), - ]; - } - - /** - * Indicate that the news has high views. - */ - public function popular(): static - { - return $this->state(fn (array $attributes) => [ - 'view' => $this->faker->numberBetween(5000, 50000), - ]); - } - - /** - * Indicate that the news has external link. - */ - public function withLink(): static - { - return $this->state(fn (array $attributes) => [ - 'link' => $this->faker->url(), - ]); - } - - /** - * Indicate that the news has no views. - */ - public function unpublished(): static - { - return $this->state(fn (array $attributes) => [ - 'view' => 0, - ]); - } -} diff --git a/database/factories/NewsTagsFactory.php b/database/factories/NewsTagsFactory.php deleted file mode 100644 index 509db56..0000000 --- a/database/factories/NewsTagsFactory.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class NewsTagsFactory extends Factory -{ - protected $model = NewsTags::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - $tags = [ - 'Berita', - 'Update', - 'Pengumuman', - 'Event', - 'Kegiatan', - 'Kominfo', - 'Diskominfo', - 'Pemerintah', - 'Publik', - 'Informasi', - 'Layanan', - 'Digital', - 'Teknologi', - 'Sosial', - 'Ekonomi', - 'Pendidikan', - 'Kesehatan', - 'Lingkungan', - 'Infrastruktur', - 'Transportasi', - ]; - - return [ - 'news_id' => News::factory(), - 'name' => $this->faker->randomElement($tags), - ]; - } - - /** - * Indicate that the tag is for news category. - */ - public function news(): static - { - return $this->state(fn (array $attributes) => [ - 'name' => 'Berita', - ]); - } - - /** - * Indicate that the tag is for announcement category. - */ - public function announcement(): static - { - return $this->state(fn (array $attributes) => [ - 'name' => 'Pengumuman', - ]); - } - - /** - * Indicate that the tag is for event category. - */ - public function event(): static - { - return $this->state(fn (array $attributes) => [ - 'name' => 'Event', - ]); - } -} diff --git a/database/factories/PartnerMediaFactory.php b/database/factories/PartnerMediaFactory.php deleted file mode 100644 index 4b26fa5..0000000 --- a/database/factories/PartnerMediaFactory.php +++ /dev/null @@ -1,120 +0,0 @@ - - */ -class PartnerMediaFactory extends Factory -{ - protected $model = PartnerMedia::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - $mediaNames = [ - 'Kompas.com', - 'Detik.com', - 'Tribun News', - 'Liputan6', - 'CNN Indonesia', - 'ANTARA News', - 'Tempo.co', - 'Okezone', - 'Suara.com', - 'Bisnis.com', - 'Media Indonesia', - 'Republika', - 'Koran Sindo', - 'Pikiran Rakyat', - ]; - - return [ - 'company_id' => Company::factory(), - 'name' => $this->faker->randomElement($mediaNames), - 'address' => $this->faker->address(), - 'link' => $this->faker->optional(0.8)->domainName(), - 'type' => $this->faker->randomElement(MediaType::cases())->value, - 'classification' => $this->faker->randomElement(MediaClassification::cases())->value, - 'journalism_organization' => $this->faker->optional(0.6)->randomElement([ - 'Persatuan Wartawan Indonesia (PWI)', - 'Aliansi Jurnalis Independen (AJI)', - 'Ikatan Jurnalis Televisi Indonesia (IJTI)', - 'Persatuan Jurnalis Online Indonesia (PJOI)', - ]), - 'press_council_certificate' => $this->faker->optional(0.7)->numerify('DEP-###/####/KP'), - ]; - } - - /** - * Indicate that the partner media is online type. - */ - public function online(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => MediaType::ONLINE->value, - 'link' => $this->faker->domainName(), - ]); - } - - /** - * Indicate that the partner media is print type. - */ - public function print(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => MediaType::PRINT->value, - 'link' => null, - ]); - } - - /** - * Indicate that the partner media is television type. - */ - public function television(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => MediaType::TELEVISION->value, - ]); - } - - /** - * Indicate that the partner media is radio type. - */ - public function radio(): static - { - return $this->state(fn (array $attributes) => [ - 'type' => MediaType::RADIO->value, - ]); - } - - /** - * Indicate that the partner media is national classification. - */ - public function national(): static - { - return $this->state(fn (array $attributes) => [ - 'classification' => MediaClassification::NATIONAL->value, - ]); - } - - /** - * Indicate that the partner media is local classification. - */ - public function local(): static - { - return $this->state(fn (array $attributes) => [ - 'classification' => MediaClassification::LOCAL->value, - ]); - } -} diff --git a/database/factories/SubClassificationFactory.php b/database/factories/SubClassificationFactory.php deleted file mode 100644 index 8d7a8a3..0000000 --- a/database/factories/SubClassificationFactory.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -class SubClassificationFactory extends Factory -{ - protected $model = SubClassification::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'classification_id' => Classification::factory(), - 'name' => $this->faker->words(2, true), - 'description' => $this->faker->sentence(), - 'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]), - 'sort_order' => $this->faker->numberBetween(0, 100), - ]; - } - - /** - * Indicate that the sub classification is active. - */ - public function active(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::ACTIVE->value, - ]); - } - - /** - * Indicate that the sub classification is inactive. - */ - public function inactive(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::INACTIVE->value, - ]); - } -} diff --git a/database/factories/SubLocationFactory.php b/database/factories/SubLocationFactory.php deleted file mode 100644 index b888f33..0000000 --- a/database/factories/SubLocationFactory.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -class SubLocationFactory extends Factory -{ - protected $model = SubLocation::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'location_id' => Location::factory(), - 'name' => $this->faker->streetName(), - 'description' => $this->faker->sentence(), - 'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]), - 'sort_order' => $this->faker->numberBetween(0, 100), - ]; - } - - /** - * Indicate that the sub location is active. - */ - public function active(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::ACTIVE->value, - ]); - } - - /** - * Indicate that the sub location is inactive. - */ - public function inactive(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::INACTIVE->value, - ]); - } -} diff --git a/database/factories/ThemeFactory.php b/database/factories/ThemeFactory.php deleted file mode 100644 index 5b008d6..0000000 --- a/database/factories/ThemeFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ -class ThemeFactory extends Factory -{ - protected $model = Theme::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => $this->faker->words(2, true), - 'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]), - 'sort_order' => $this->faker->numberBetween(0, 100), - ]; - } - - /** - * Indicate that the theme is active. - */ - public function active(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::ACTIVE->value, - ]); - } - - /** - * Indicate that the theme is inactive. - */ - public function inactive(): static - { - return $this->state(fn (array $attributes) => [ - 'is_active' => IsActive::INACTIVE->value, - ]); - } -} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php deleted file mode 100644 index fa69d4f..0000000 --- a/database/factories/UserFactory.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class UserFactory extends Factory -{ - /** - * The current password being used by the factory. - */ - protected static ?string $password; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => fake()->name(), - 'email' => fake()->unique()->safeEmail(), - 'username' => $this->faker->unique()->bothify('?????#####'), - 'email_verified_at' => now(), - 'password' => static::$password ??= Hash::make(config('auth.password_default')), - 'remember_token' => Str::random(10), - ]; - } - - /** - * Indicate that the model's email address should be unverified. - */ - public function unverified(): static - { - return $this->state(fn (array $attributes) => [ - 'email_verified_at' => null, - ]); - } -} diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 3e3f9f0..895120f 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -20,7 +20,7 @@ public function up(): void $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE)->comment(IsActive::comment()); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment())->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_10_24_012236_create_classifications_table.php b/database/migrations/2025_10_24_012236_create_classifications_table.php index 1e1b8d4..76331c7 100644 --- a/database/migrations/2025_10_24_012236_create_classifications_table.php +++ b/database/migrations/2025_10_24_012236_create_classifications_table.php @@ -14,10 +14,10 @@ public function up(): void { Schema::create('classifications', function (Blueprint $table) { $table->id(); - $table->string('name', 50); + $table->string('name', 50)->index(); $table->text('description')->nullable(); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->integer('sort_order')->default(0); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment())->index(); + $table->integer('sort_order')->default(0)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_11_19_082630_create_sub_classifications_table.php b/database/migrations/2025_11_19_082630_create_sub_classifications_table.php index 1c48adb..c645f3a 100644 --- a/database/migrations/2025_11_19_082630_create_sub_classifications_table.php +++ b/database/migrations/2025_11_19_082630_create_sub_classifications_table.php @@ -15,10 +15,10 @@ public function up(): void Schema::create('sub_classifications', function (Blueprint $table) { $table->id(); $table->foreignId('classification_id')->constrained()->cascadeOnDelete(); - $table->string('name', 50); + $table->string('name', 50)->index(); $table->text('description')->nullable(); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->integer('sort_order')->default(0); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); + $table->integer('sort_order')->default(0)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_11_19_084250_create_locations_table.php b/database/migrations/2025_11_19_084250_create_locations_table.php index aa27036..38c6b89 100644 --- a/database/migrations/2025_11_19_084250_create_locations_table.php +++ b/database/migrations/2025_11_19_084250_create_locations_table.php @@ -14,10 +14,10 @@ public function up(): void { Schema::create('locations', function (Blueprint $table) { $table->id(); - $table->string('name', 50); + $table->string('name', 50)->index(); $table->text('description')->nullable(); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->integer('sort_order')->default(0); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment())->index(); + $table->integer('sort_order')->default(0)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_11_19_084252_create_sub_locations_table.php b/database/migrations/2025_11_19_084252_create_sub_locations_table.php index fc8102e..78fa8c3 100644 --- a/database/migrations/2025_11_19_084252_create_sub_locations_table.php +++ b/database/migrations/2025_11_19_084252_create_sub_locations_table.php @@ -15,10 +15,10 @@ public function up(): void Schema::create('sub_locations', function (Blueprint $table) { $table->id(); $table->foreignId('location_id')->constrained()->cascadeOnDelete(); - $table->string('name', 50); + $table->string('name', 50)->index(); $table->text('description')->nullable(); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->integer('sort_order')->default(0); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); + $table->integer('sort_order')->default(0)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_11_19_085234_create_departments_table.php b/database/migrations/2025_11_19_085234_create_departments_table.php index dda0c90..a2c1add 100644 --- a/database/migrations/2025_11_19_085234_create_departments_table.php +++ b/database/migrations/2025_11_19_085234_create_departments_table.php @@ -14,10 +14,10 @@ public function up(): void { Schema::create('departments', function (Blueprint $table) { $table->id(); - $table->string('name', 100); - $table->string('alias', 20); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->integer('sort_order')->default(0); + $table->string('name', 100)->index(); + $table->string('alias', 20)->index(); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment())->index(); + $table->integer('sort_order')->default(0)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_11_19_092038_create_themes_table.php b/database/migrations/2025_11_19_092038_create_themes_table.php index e0b790e..e5adf63 100644 --- a/database/migrations/2025_11_19_092038_create_themes_table.php +++ b/database/migrations/2025_11_19_092038_create_themes_table.php @@ -14,9 +14,9 @@ public function up(): void { Schema::create('themes', function (Blueprint $table) { $table->id(); - $table->string('name', 50); - $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->integer('sort_order')->default(0); + $table->string('name', 50)->index(); + $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment())->index(); + $table->integer('sort_order')->default(0)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_11_20_041121_create_companies_table.php b/database/migrations/2025_11_20_041121_create_companies_table.php index 751df5c..840f741 100644 --- a/database/migrations/2025_11_20_041121_create_companies_table.php +++ b/database/migrations/2025_11_20_041121_create_companies_table.php @@ -1,6 +1,5 @@ id(); - $table->foreignIdFor(User::class); - $table->string('name', 100); - $table->string('email', 254); + $table->foreignId('user_id')->constrained()->cascadeOnDelete(); + $table->string('name', 100)->index(); + $table->string('email', 254)->index(); $table->text('address'); $table->string('director_name', 100); $table->string('director_nik', 16); diff --git a/database/migrations/2025_11_20_041125_create_partner_media_table.php b/database/migrations/2025_11_20_041125_create_partner_media_table.php index 8b35d19..7755714 100644 --- a/database/migrations/2025_11_20_041125_create_partner_media_table.php +++ b/database/migrations/2025_11_20_041125_create_partner_media_table.php @@ -2,7 +2,6 @@ use App\Enums\MediaClassification; use App\Enums\MediaType; -use App\Models\Company; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,12 +15,12 @@ public function up(): void { Schema::create('partner_media', function (Blueprint $table) { $table->id(); - $table->foreignIdFor(Company::class); - $table->string('name', 50); + $table->foreignId('company_id')->constrained()->cascadeOnDelete(); + $table->string('name', 50)->index(); $table->text('address'); $table->string('link', 50)->nullable(); - $table->enum('type', [MediaType::values()])->default(MediaType::ONLINE)->comment(MediaType::comment()); - $table->enum('classification', [MediaClassification::values()])->comment(MediaClassification::comment()); + $table->enum('type', MediaType::values())->default(MediaType::ONLINE)->comment(MediaType::comment())->index(); + $table->enum('classification', MediaClassification::values())->comment(MediaClassification::comment())->index(); $table->string('journalism_organization')->nullable(); $table->string('press_council_certificate')->nullable(); $table->timestamp('created_at')->useCurrent(); diff --git a/database/migrations/2025_11_20_041138_create_journalists_table.php b/database/migrations/2025_11_20_041138_create_journalists_table.php index f1802d3..5951238 100644 --- a/database/migrations/2025_11_20_041138_create_journalists_table.php +++ b/database/migrations/2025_11_20_041138_create_journalists_table.php @@ -1,6 +1,5 @@ id(); - $table->foreignIdFor(PartnerMedia::class); - $table->string('name', 100); - $table->string('email', 254); - $table->string('phone_number', 20); + $table->foreignId('partner_media_id')->constrained()->cascadeOnDelete(); + $table->string('name', 100)->index(); + $table->string('email', 254)->index(); + $table->string('phone_number', 20)->index(); $table->string('press_card', 100)->nullable(); $table->string('ukw_certificate', 100)->nullable(); $table->timestamp('created_at')->useCurrent(); diff --git a/database/migrations/2025_12_05_095022_create_media_monitorings_table.php b/database/migrations/2025_12_05_095022_create_media_monitorings_table.php index 004efb1..65f4873 100644 --- a/database/migrations/2025_12_05_095022_create_media_monitorings_table.php +++ b/database/migrations/2025_12_05_095022_create_media_monitorings_table.php @@ -14,17 +14,17 @@ public function up(): void Schema::create('media_monitorings', function (Blueprint $table) { $table->id(); $table->string('code', 10); - $table->string('media_name', 50); + $table->string('media_name', 50)->index(); $table->text('title', 255); - $table->string('channel', 20); + $table->string('channel', 20)->index(); $table->string('writter', 50); $table->text('link', 50)->nullable(); $table->string('news_page', 20)->nullable(); $table->text('quote')->nullable(); $table->text('content'); $table->string('influencer', 50)->nullable(); - $table->string('keyword', 100); - $table->date('release_date'); + $table->string('keyword', 100)->index(); + $table->date('release_date')->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_12_05_100045_create_media_monitoring_theme_table.php b/database/migrations/2025_12_05_100045_create_media_monitoring_theme_table.php index 5542bc9..cacfe5f 100644 --- a/database/migrations/2025_12_05_100045_create_media_monitoring_theme_table.php +++ b/database/migrations/2025_12_05_100045_create_media_monitoring_theme_table.php @@ -1,7 +1,5 @@ id(); - $table->foreignIdFor(MediaMonitoring::class); - $table->foreignIdFor(Theme::class); + $table->foreignId('media_monitoring_id')->constrained()->cascadeOnDelete(); + $table->foreignId('theme_id')->constrained()->cascadeOnDelete(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); }); diff --git a/database/migrations/2025_12_09_113331_create_content_recaps_table.php b/database/migrations/2025_12_09_113331_create_content_recaps_table.php index 160d0cf..9250c5b 100644 --- a/database/migrations/2025_12_09_113331_create_content_recaps_table.php +++ b/database/migrations/2025_12_09_113331_create_content_recaps_table.php @@ -1,7 +1,6 @@ id(); - $table->foreignIdFor(Classification::class)->constrained(); + $table->foreignId('classification_id')->constrained()->cascadeOnDelete(); $table->string('title', 255); $table->text('link', 50)->nullable(); - $table->date('posting_date'); - $table->enum('type', [ContentType::values()])->default(ContentType::FOTO); - $table->string('channel', 20); - $table->string('social_media', 50); + $table->date('posting_date')->index(); + $table->enum('type', ContentType::values())->default(ContentType::FOTO)->index(); + $table->string('channel', 20)->index(); + $table->string('social_media', 50)->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_12_10_144144_create_issue_management_table.php b/database/migrations/2025_12_10_144144_create_issue_management_table.php index ba13b7f..6214e72 100644 --- a/database/migrations/2025_12_10_144144_create_issue_management_table.php +++ b/database/migrations/2025_12_10_144144_create_issue_management_table.php @@ -1,11 +1,6 @@ id(); - $table->foreignIdFor(Location::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(SubLocation::class)->nullable()->constrained()->nullOnDelete(); - $table->foreignIdFor(Classification::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(SubClassification::class)->nullable()->constrained()->nullOnDelete(); - $table->foreignIdFor(MediaMonitoring::class)->constrained()->cascadeOnDelete(); - $table->enum('issue', [IssueSentiment::values()])->comment(IssueSentiment::comment()); - $table->enum('response', [IssueSentiment::values()])->comment(IssueSentiment::comment()); + $table->foreignId('location_id')->constrained()->cascadeOnDelete(); + $table->foreignId('sub_location_id')->nullable()->constrained()->nullOnDelete(); + $table->foreignId('classification_id')->constrained()->cascadeOnDelete(); + $table->foreignId('sub_classification_id')->nullable()->constrained()->nullOnDelete(); + $table->foreignId('media_monitoring_id')->constrained()->cascadeOnDelete(); + $table->enum('issue', IssueSentiment::values())->comment(IssueSentiment::comment())->index(); + $table->enum('response', IssueSentiment::values())->comment(IssueSentiment::comment())->index(); $table->text('description'); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); diff --git a/database/migrations/2025_12_12_082036_create_news_table.php b/database/migrations/2025_12_12_082036_create_news_table.php index d558310..8d3247b 100644 --- a/database/migrations/2025_12_12_082036_create_news_table.php +++ b/database/migrations/2025_12_12_082036_create_news_table.php @@ -1,7 +1,6 @@ id(); - $table->foreignIdFor(User::class, 'author_id'); + $table->foreignId('author_id')->constrained('users')->cascadeOnDelete(); $table->string('title', 200); - $table->string('slug', 200); + $table->string('slug', 200)->index(); $table->text('content'); $table->text('excerpt'); $table->string('link', 50)->nullable(); - $table->unsignedInteger('views')->default(0); - $table->enum('status', [NewsStatus::values()])->comment(NewsStatus::comment()); - $table->timestamp('published_at')->nullable(); + $table->unsignedInteger('views')->default(0)->index(); + $table->enum('status', NewsStatus::values())->comment(NewsStatus::comment())->index(); + $table->timestamp('published_at')->nullable()->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_12_12_111212_create_cooperations_table.php b/database/migrations/2025_12_12_111212_create_cooperations_table.php index 5069550..0d6890e 100644 --- a/database/migrations/2025_12_12_111212_create_cooperations_table.php +++ b/database/migrations/2025_12_12_111212_create_cooperations_table.php @@ -15,13 +15,13 @@ public function up(): void Schema::create('cooperations', function (Blueprint $table) { $table->id(); $table->string('title', 200); - $table->date('initial_submission_date'); - $table->date('final_submission_date'); + $table->date('initial_submission_date')->index(); + $table->date('final_submission_date')->index(); $table->text('description'); $table->unsignedInteger('payment_amount')->nullable(); $table->date('payment_date')->nullable(); $table->date('completed_at')->nullable(); - $table->enum('status', CooperationStatus::values())->default(CooperationStatus::PENDING)->comment(CooperationStatus::comment()); + $table->enum('status', CooperationStatus::values())->default(CooperationStatus::PENDING)->comment(CooperationStatus::comment())->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_12_12_111307_create_cooperation_media_table.php b/database/migrations/2025_12_12_111307_create_cooperation_media_table.php index d8f8cea..a6fe42f 100644 --- a/database/migrations/2025_12_12_111307_create_cooperation_media_table.php +++ b/database/migrations/2025_12_12_111307_create_cooperation_media_table.php @@ -1,8 +1,6 @@ id(); - $table->foreignIdFor(Cooperation::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(PartnerMedia::class)->constrained()->cascadeOnDelete(); - $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING)->comment(ApprovalStatus::comment()); + $table->foreignId('cooperation_id')->constrained()->cascadeOnDelete(); + $table->foreignId('partner_media_id')->constrained()->cascadeOnDelete(); + $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING)->comment(ApprovalStatus::comment())->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); }); diff --git a/database/migrations/2025_12_12_132453_create_task_assignments_table.php b/database/migrations/2025_12_12_132453_create_task_assignments_table.php index c150d67..4e919e3 100644 --- a/database/migrations/2025_12_12_132453_create_task_assignments_table.php +++ b/database/migrations/2025_12_12_132453_create_task_assignments_table.php @@ -1,6 +1,5 @@ id(); - $table->foreignIdFor(Cooperation::class)->constrained()->cascadeOnDelete(); - $table->date('start_date'); - $table->date('end_date'); + $table->foreignId('cooperation_id')->constrained()->cascadeOnDelete(); + $table->date('start_date')->index(); + $table->date('end_date')->index(); $table->text('task_description'); $table->unsignedInteger('report_amount'); $table->timestamp('created_at')->useCurrent(); diff --git a/database/migrations/2025_12_12_133823_create_media_task_assignment_table.php b/database/migrations/2025_12_12_133823_create_media_task_assignment_table.php index 2de977b..a10573c 100644 --- a/database/migrations/2025_12_12_133823_create_media_task_assignment_table.php +++ b/database/migrations/2025_12_12_133823_create_media_task_assignment_table.php @@ -1,8 +1,6 @@ id(); - $table->foreignIdFor(TaskAssignment::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(PartnerMedia::class)->constrained()->cascadeOnDelete(); - $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING)->comment(ApprovalStatus::comment()); + $table->foreignId('task_assignment_id')->constrained()->cascadeOnDelete(); + $table->foreignId('partner_media_id')->constrained()->cascadeOnDelete(); + $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING)->comment(ApprovalStatus::comment())->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); }); diff --git a/database/migrations/2025_12_12_135847_create_reports_table.php b/database/migrations/2025_12_12_135847_create_reports_table.php index dcb3952..a1b4505 100644 --- a/database/migrations/2025_12_12_135847_create_reports_table.php +++ b/database/migrations/2025_12_12_135847_create_reports_table.php @@ -1,7 +1,6 @@ id(); - $table->foreignIdFor(MediaTaskAssignment::class)->constrained()->cascadeOnDelete(); + $table->foreignId('media_task_assignment_id')->constrained('media_task_assignment')->cascadeOnDelete(); $table->string('title', 200); - $table->date('publication_date'); + $table->date('publication_date')->index(); $table->string('link', 50); $table->text('description'); - $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING)->comment(ApprovalStatus::comment()); + $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING)->comment(ApprovalStatus::comment())->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_12_22_130245_create_verification_requests_table.php b/database/migrations/2025_12_22_130245_create_verification_requests_table.php index 45087db..8f394d0 100644 --- a/database/migrations/2025_12_22_130245_create_verification_requests_table.php +++ b/database/migrations/2025_12_22_130245_create_verification_requests_table.php @@ -1,8 +1,6 @@ id(); - $table->foreignIdFor(Company::class); - $table->foreignIdFor(User::class, 'submitted_by'); - $table->enum('status', VerificationStatus::cases())->default(VerificationStatus::PENDING)->comment(VerificationStatus::comment()); + $table->foreignId('company_id')->constrained()->cascadeOnDelete(); + $table->foreignId('submitted_by')->constrained('users')->cascadeOnDelete(); + $table->enum('status', VerificationStatus::values())->default(VerificationStatus::PENDING->value)->comment(VerificationStatus::comment())->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->softDeletes(); diff --git a/database/migrations/2025_12_22_130256_create_verification_reviews_table.php b/database/migrations/2025_12_22_130256_create_verification_reviews_table.php index 7388576..6dc0ae0 100644 --- a/database/migrations/2025_12_22_130256_create_verification_reviews_table.php +++ b/database/migrations/2025_12_22_130256_create_verification_reviews_table.php @@ -1,8 +1,6 @@ id(); - $table->foreignIdFor(VerificationRequest::class); - $table->foreignIdFor(User::class, 'reviewer_id'); - $table->enum('decision', DecisionAdmin::cases())->comment(DecisionAdmin::comment()); + $table->foreignId('verification_request_id')->constrained()->cascadeOnDelete(); + $table->foreignId('reviewer_id')->constrained('users')->cascadeOnDelete(); + $table->enum('decision', DecisionAdmin::values())->comment(DecisionAdmin::comment())->index(); $table->text('note')->nullable(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); diff --git a/database/migrations/2026_01_14_140256_create_cooperation_payments_table.php b/database/migrations/2026_01_14_140256_create_cooperation_payments_table.php index 6bd0dff..73f16b3 100644 --- a/database/migrations/2026_01_14_140256_create_cooperation_payments_table.php +++ b/database/migrations/2026_01_14_140256_create_cooperation_payments_table.php @@ -1,6 +1,5 @@ id(); - $table->foreignIdFor(CooperationMedia::class, 'cooperation_media_id')->constrained()->cascadeOnDelete(); - $table->unsignedInteger('amount'); + $table->foreignId('cooperation_media_id')->constrained('cooperation_media')->cascadeOnDelete(); + $table->unsignedInteger('amount')->index(); $table->text('description')->nullable(); - $table->date('payment_date')->useCurrent(); + $table->date('payment_date')->useCurrent()->index(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); }); diff --git a/database/migrations/2026_01_28_110008_create_data_change_requests_table.php b/database/migrations/2026_01_28_110008_create_data_change_requests_table.php index e4f4227..f9b36fe 100644 --- a/database/migrations/2026_01_28_110008_create_data_change_requests_table.php +++ b/database/migrations/2026_01_28_110008_create_data_change_requests_table.php @@ -1,7 +1,6 @@ id(); - $table->foreignIdFor(User::class); + $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->morphs('entity'); - $table->enum('status', DataChangeStatus::cases())->default(DataChangeStatus::PENDING)->comment(DataChangeStatus::comment()); + $table->enum('status', DataChangeStatus::values())->default(DataChangeStatus::PENDING->value)->comment(DataChangeStatus::comment())->index(); $table->json('old_data')->nullable(); $table->json('new_data'); $table->text('change_reason')->nullable(); diff --git a/database/migrations/2026_01_28_110032_create_data_change_reviews_table.php b/database/migrations/2026_01_28_110032_create_data_change_reviews_table.php index b900f2b..1fed787 100644 --- a/database/migrations/2026_01_28_110032_create_data_change_reviews_table.php +++ b/database/migrations/2026_01_28_110032_create_data_change_reviews_table.php @@ -1,8 +1,6 @@ id(); - $table->foreignIdFor(DataChangeRequest::class); - $table->foreignIdFor(User::class, 'reviewer_id'); - $table->enum('decision', DataChangeDecision::cases())->comment(DataChangeDecision::comment()); + $table->foreignId('data_change_request_id')->constrained()->cascadeOnDelete(); + $table->foreignId('reviewer_id')->constrained('users')->cascadeOnDelete(); + $table->enum('decision', DataChangeDecision::values())->comment(DataChangeDecision::comment())->index(); $table->text('note')->nullable(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();