Refactor database migrations to use explicit foreign key constraints with cascade on delete, update enum column definitions to use enum values and add indexes, and refine model casts.
This commit is contained in:
parent
2d7f4ee0e8
commit
7f51781334
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -22,6 +22,7 @@ protected function casts(): array
|
||||
return [
|
||||
'type' => ContentType::class,
|
||||
'posting_date' => 'date',
|
||||
'classification_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,8 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => ApprovalStatus::class,
|
||||
'cooperation_id' => 'integer',
|
||||
'partner_media_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ protected function casts(): array
|
||||
return [
|
||||
'amount' => 'integer',
|
||||
'payment_date' => 'date',
|
||||
'cooperation_media_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'decision' => DataChangeDecision::class,
|
||||
'data_change_request_id' => 'integer',
|
||||
'reviewer_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ protected function casts(): array
|
||||
return [
|
||||
'type' => MediaType::class,
|
||||
'classification' => MediaClassification::class,
|
||||
'company_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -23,6 +23,7 @@ protected function casts(): array
|
||||
return [
|
||||
'publication_date' => 'date',
|
||||
'status' => ApprovalStatus::class,
|
||||
'media_task_assignment_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ protected function casts(): array
|
||||
return [
|
||||
'is_active' => IsActive::class,
|
||||
'sort_order' => 'integer',
|
||||
'classification_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ protected function casts(): array
|
||||
return [
|
||||
'is_active' => IsActive::class,
|
||||
'sort_order' => 'integer',
|
||||
'location_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -21,6 +21,8 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => VerificationStatus::class,
|
||||
'company_id' => 'integer',
|
||||
'submitted_by' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -14,9 +13,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->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);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\PartnerMedia;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -14,10 +13,10 @@ public function up(): void
|
||||
{
|
||||
Schema::create('journalists', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\Theme;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -15,8 +13,8 @@ public function up(): void
|
||||
{
|
||||
Schema::create('media_monitoring_theme', function (Blueprint $table) {
|
||||
$table->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();
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ContentType;
|
||||
use App\Models\Classification;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -15,13 +14,13 @@ public function up(): void
|
||||
{
|
||||
Schema::create('content_recaps', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
use App\Models\Classification;
|
||||
use App\Models\Location;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\SubClassification;
|
||||
use App\Models\SubLocation;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -19,13 +14,13 @@ public function up(): void
|
||||
{
|
||||
Schema::create('issue_management', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\NewsStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -15,15 +14,15 @@ public function up(): void
|
||||
{
|
||||
Schema::create('news', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\PartnerMedia;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -16,9 +14,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('cooperation_media', function (Blueprint $table) {
|
||||
$table->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();
|
||||
});
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Cooperation;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -14,9 +13,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('task_assignments', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\TaskAssignment;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -16,9 +14,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('media_task_assignment', function (Blueprint $table) {
|
||||
$table->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();
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\MediaTaskAssignment;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -15,12 +14,12 @@ public function up(): void
|
||||
{
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(MediaTaskAssignment::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('media_task_assignment_id')->constrained()->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();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\VerificationStatus;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -16,9 +14,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('verification_requests', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\DecisionAdmin;
|
||||
use App\Models\User;
|
||||
use App\Models\VerificationRequest;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -16,9 +14,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('verification_reviews', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\CooperationMedia;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -14,10 +13,10 @@ public function up(): void
|
||||
{
|
||||
Schema::create('cooperation_payments', function (Blueprint $table) {
|
||||
$table->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();
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\DataChangeStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -15,9 +14,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('data_change_requests', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\DataChangeDecision;
|
||||
use App\Models\DataChangeRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -16,9 +14,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('data_change_reviews', function (Blueprint $table) {
|
||||
$table->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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user