Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions database/migrations/2023_05_18_113529_add_tasks_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ public function up(): void
$table->string('name');
$table->text('description')->nullable();
$table->enum('status', ['pending', 'completed', 'running'])->default('pending');
$table->unsignedBigInteger('owner_id')->nullable();
$table->string('owner_class')->nullable();
$table->unsignedBigInteger('assignee_id')->nullable();
$table->string('assignee_class')->nullable();
$table->morphs('creator');
$table->morphs('assignee');
$table->string('job')->nullable();
$table->text('job_data')->nullable();
$table->timestamp('due_date')->nullable();
Expand Down
9 changes: 3 additions & 6 deletions src/Models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Task extends Model
const STATUS_COMPLETED = 'completed';
const STATUS_RUNNING = 'running';

protected $fillable = [
protected array $fillable = [
'name',
'description',
'status',
Expand All @@ -31,20 +31,17 @@ class Task extends Model
'completed_by',
];

/**
* @return MorphTo
*/
public function owner(): MorphTo
{
return $this->morphTo('owner', 'owner_class', 'owner_id');
return $this->morphTo();
}

/**
* @return MorphTo
*/
public function assignee(): MorphTo
{
return $this->morphTo('assignee', 'assignee_class', 'assignee_id');
return $this->morphTo();
}

/**
Expand Down
Loading