From d32be18c92fa58f18a91228010e8c07d1ee5a160 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 6 Apr 2026 13:52:43 +0700 Subject: [PATCH] refactor: remove unused casts and rename announcementMedias relation to announcementMedia for consistency --- app/Models/Announcement.php | 2 +- app/Models/AnnouncementMedia.php | 8 -------- app/Models/CategoryNews.php | 8 -------- app/Models/Company.php | 7 ------- app/Models/ContentRecap.php | 1 - app/Models/CooperationMedia.php | 2 -- app/Models/CooperationPayment.php | 1 - app/Models/DataChangeRequest.php | 2 -- app/Models/DataChangeReview.php | 2 -- app/Models/IssueManagement.php | 15 +++++---------- app/Models/Journalist.php | 2 +- app/Models/MediaMonitoringTheme.php | 8 -------- app/Models/MediaTaskAssignment.php | 2 -- app/Models/News.php | 1 - app/Models/PartnerMedia.php | 3 +-- app/Models/RejectionReason.php | 7 ------- app/Models/Report.php | 1 - app/Models/SubClassification.php | 1 - app/Models/SubLocation.php | 1 - app/Models/TaskAssignment.php | 1 - app/Models/VerificationRequest.php | 10 ++++------ app/Models/VerificationReview.php | 2 -- app/Models/Visitor.php | 2 -- 23 files changed, 12 insertions(+), 77 deletions(-) diff --git a/app/Models/Announcement.php b/app/Models/Announcement.php index 0bfb6d6..e9ce28a 100644 --- a/app/Models/Announcement.php +++ b/app/Models/Announcement.php @@ -37,7 +37,7 @@ protected function company(Builder $query): void $query->where('type', AnnouncementType::COMPANY); } - public function announcementMedias(): HasMany + public function announcementMedia(): HasMany { return $this->hasMany(AnnouncementMedia::class); } diff --git a/app/Models/AnnouncementMedia.php b/app/Models/AnnouncementMedia.php index 9c7804e..6587216 100644 --- a/app/Models/AnnouncementMedia.php +++ b/app/Models/AnnouncementMedia.php @@ -13,14 +13,6 @@ 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/CategoryNews.php b/app/Models/CategoryNews.php index 2a33051..ccd307d 100644 --- a/app/Models/CategoryNews.php +++ b/app/Models/CategoryNews.php @@ -13,14 +13,6 @@ class CategoryNews extends Model protected $guarded = ['id']; - protected function casts(): array - { - return [ - 'category_id' => 'integer', - 'news_id' => 'integer', - ]; - } - public function category(): BelongsTo { return $this->belongsTo(Category::class); diff --git a/app/Models/Company.php b/app/Models/Company.php index 96d00e6..5fcf1ae 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -19,13 +19,6 @@ class Company extends Model implements HasMedia protected $guarded = ['id']; - protected function casts(): array - { - return [ - 'user_id' => 'integer', - ]; - } - public static function dataChangeEntryLabels(): array { return [ diff --git a/app/Models/ContentRecap.php b/app/Models/ContentRecap.php index 7348839..3c9fe33 100644 --- a/app/Models/ContentRecap.php +++ b/app/Models/ContentRecap.php @@ -26,7 +26,6 @@ protected function casts(): array 'channel' => Channel::class, 'social_media' => SocialMedia::class, 'posting_date' => 'date', - 'classification_id' => 'integer', ]; } diff --git a/app/Models/CooperationMedia.php b/app/Models/CooperationMedia.php index f02379e..f4b589b 100644 --- a/app/Models/CooperationMedia.php +++ b/app/Models/CooperationMedia.php @@ -28,8 +28,6 @@ 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 3e02c49..467abef 100644 --- a/app/Models/CooperationPayment.php +++ b/app/Models/CooperationPayment.php @@ -20,7 +20,6 @@ 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 fed731b..b1e9892 100644 --- a/app/Models/DataChangeRequest.php +++ b/app/Models/DataChangeRequest.php @@ -25,8 +25,6 @@ protected function casts(): array 'status' => DataChangeStatus::class, 'old_data' => 'array', 'new_data' => 'array', - 'user_id' => 'integer', - 'entity_id' => 'integer', ]; } diff --git a/app/Models/DataChangeReview.php b/app/Models/DataChangeReview.php index cf7b399..3aebe91 100644 --- a/app/Models/DataChangeReview.php +++ b/app/Models/DataChangeReview.php @@ -18,8 +18,6 @@ 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 9729e0b..06633e2 100644 --- a/app/Models/IssueManagement.php +++ b/app/Models/IssueManagement.php @@ -21,11 +21,6 @@ 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', ]; } @@ -34,6 +29,11 @@ public function classification(): BelongsTo return $this->belongsTo(Classification::class); } + public function departments(): BelongsToMany + { + return $this->belongsToMany(Department::class, 'department_issue_management'); + } + public function location(): BelongsTo { return $this->belongsTo(Location::class); @@ -53,9 +53,4 @@ public function subLocation(): BelongsTo { return $this->belongsTo(SubLocation::class); } - - public function departments(): BelongsToMany - { - return $this->belongsToMany(Department::class, 'department_issue_management'); - } } diff --git a/app/Models/Journalist.php b/app/Models/Journalist.php index 28102c0..46729e1 100644 --- a/app/Models/Journalist.php +++ b/app/Models/Journalist.php @@ -23,7 +23,7 @@ class Journalist extends Model implements HasMedia protected function casts(): array { return [ - 'partner_media_id' => 'integer', + 'status' => VerificationStatus::class, ]; } diff --git a/app/Models/MediaMonitoringTheme.php b/app/Models/MediaMonitoringTheme.php index 92d5c17..39858ae 100644 --- a/app/Models/MediaMonitoringTheme.php +++ b/app/Models/MediaMonitoringTheme.php @@ -15,14 +15,6 @@ 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 857b3d6..5f04e27 100644 --- a/app/Models/MediaTaskAssignment.php +++ b/app/Models/MediaTaskAssignment.php @@ -24,8 +24,6 @@ protected function casts(): array { return [ 'status' => ApprovalStatus::class, - 'task_assignment_id' => 'integer', - 'partner_media_id' => 'integer', ]; } diff --git a/app/Models/News.php b/app/Models/News.php index 423508d..a888a0b 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -26,7 +26,6 @@ class News extends Model implements HasMedia protected function casts(): array { return [ - 'author_id' => 'integer', 'published_at' => 'datetime', 'status' => NewsStatus::class, 'views' => 'integer', diff --git a/app/Models/PartnerMedia.php b/app/Models/PartnerMedia.php index da37d22..445b157 100644 --- a/app/Models/PartnerMedia.php +++ b/app/Models/PartnerMedia.php @@ -29,7 +29,6 @@ protected function casts(): array return [ 'type' => MediaType::class, 'classification' => MediaClassification::class, - 'company_id' => 'integer', ]; } @@ -74,7 +73,7 @@ public static function dataChangeEntryLabels(): array ]; } - public function announcementMedias(): HasMany + public function announcementMedia(): HasMany { return $this->hasMany(AnnouncementMedia::class); } diff --git a/app/Models/RejectionReason.php b/app/Models/RejectionReason.php index 5711c3a..129988d 100644 --- a/app/Models/RejectionReason.php +++ b/app/Models/RejectionReason.php @@ -13,13 +13,6 @@ 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 cac8282..f5a935e 100644 --- a/app/Models/Report.php +++ b/app/Models/Report.php @@ -25,7 +25,6 @@ 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 da3648f..ee72e4b 100644 --- a/app/Models/SubClassification.php +++ b/app/Models/SubClassification.php @@ -22,7 +22,6 @@ protected function casts(): array { return [ 'is_active' => IsActive::class, - 'classification_id' => 'integer', ]; } diff --git a/app/Models/SubLocation.php b/app/Models/SubLocation.php index cdc5c7e..ad04c8b 100644 --- a/app/Models/SubLocation.php +++ b/app/Models/SubLocation.php @@ -22,7 +22,6 @@ protected function casts(): array { return [ 'is_active' => IsActive::class, - 'location_id' => 'integer', ]; } diff --git a/app/Models/TaskAssignment.php b/app/Models/TaskAssignment.php index 60b9e2d..2c4ea88 100644 --- a/app/Models/TaskAssignment.php +++ b/app/Models/TaskAssignment.php @@ -23,7 +23,6 @@ protected function casts(): array 'start_date' => 'date', 'end_date' => 'date', 'report_amount' => 'integer', - 'cooperation_id' => 'integer', ]; } diff --git a/app/Models/VerificationRequest.php b/app/Models/VerificationRequest.php index f40d61f..0b87064 100644 --- a/app/Models/VerificationRequest.php +++ b/app/Models/VerificationRequest.php @@ -23,8 +23,6 @@ protected function casts(): array { return [ 'status' => VerificationStatus::class, - 'company_id' => 'integer', - 'submitted_by' => 'integer', ]; } @@ -57,9 +55,9 @@ public function company(): BelongsTo return $this->belongsTo(Company::class); } - public function submittedBy(): BelongsTo + public function latestReview(): HasOne { - return $this->belongsTo(User::class, 'submitted_by'); + return $this->hasOne(VerificationReview::class)->latestOfMany(); } public function reviews(): HasMany @@ -67,8 +65,8 @@ public function reviews(): HasMany return $this->hasMany(VerificationReview::class); } - public function latestReview(): HasOne + public function submittedBy(): BelongsTo { - return $this->hasOne(VerificationReview::class)->latestOfMany(); + return $this->belongsTo(User::class, 'submitted_by'); } } diff --git a/app/Models/VerificationReview.php b/app/Models/VerificationReview.php index 878b09d..ddde81f 100644 --- a/app/Models/VerificationReview.php +++ b/app/Models/VerificationReview.php @@ -21,8 +21,6 @@ protected function casts(): array { return [ 'decision' => DecisionAdmin::class, - 'verification_request_id' => 'integer', - 'reviewer_id' => 'integer', ]; } diff --git a/app/Models/Visitor.php b/app/Models/Visitor.php index 5bd05a1..21291a7 100644 --- a/app/Models/Visitor.php +++ b/app/Models/Visitor.php @@ -10,8 +10,6 @@ class Visitor extends BaseRouteStatistic { use HasFactory; - protected $table = 'visitors'; - public function user(): BelongsTo { return $this->belongsTo(User::class);