35 lines
689 B
PHP
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);
|
|
}
|
|
}
|