Files
Caramel-CRM/app/Models/Todo.php
T

59 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Todo extends Model
{
use HasFactory;
protected $primaryKey = 'id';
public $incrementing = false;
protected $keyType = 'string';
// Wir verwalten created_at / last_modified manuell
public $timestamps = false;
protected $fillable = [
'id',
'etag',
'title',
'description',
'type_id',
'url',
'due_date',
'recurring',
'priority',
'status',
'created_at',
'last_modified',
'parent',
'object',
'todoable_id',
'todoable_type'
];
protected $casts = [
'due_date' => 'datetime',
'created_at' => 'datetime',
'last_modified' => 'datetime',
];
public function type()
{
return $this->belongsTo(TodoType::class, 'type_id');
}
public function parentTodo()
{
return $this->belongsTo(self::class, 'parent');
}
public function children()
{
return $this->hasMany(self::class, 'parent');
}
}