Files
coruna-lab/app/Models/Note.php
T
2026-09-08 04:53:35 +08:00

35 lines
689 B
PHP

<?php
namespace App\Models;
use App\Support\NoteContent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Note extends Model
{
protected $fillable = [
'device_id', 'content', 'content_hash',
];
protected function casts(): array
{
return [
'content' => 'array',
];
}
/**
* @return list<array{title: string, body: string, native_id: int|string|null}>
*/
public function items(): array
{
return NoteContent::normalizeStored($this->content);
}
public function device(): BelongsTo
{
return $this->belongsTo(Device::class);
}
}