55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\PriorityStatus;
|
|
use App\Enums\TodoProgress;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Laravel\Scout\Searchable;
|
|
|
|
class Todo extends Model
|
|
{
|
|
use HasFactory, Searchable;
|
|
|
|
protected $table = 'todo';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'status',
|
|
'description',
|
|
'image_url',
|
|
'due_date',
|
|
'priority',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => TodoProgress::class,
|
|
'due_date' => 'date',
|
|
'priority' => PriorityStatus::class,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the indexable data array for the model.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toSearchableArray(): array
|
|
{
|
|
$array = $this->toArray();
|
|
|
|
// Customize the data array...
|
|
|
|
return $array;
|
|
}
|
|
}
|