feat: note

This commit is contained in:
hashbro
2026-09-08 04:53:35 +08:00
parent 9626fcc598
commit c1d24ab815
19 changed files with 870 additions and 58 deletions
+10 -1
View File
@@ -2,13 +2,14 @@
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',
'device_id', 'content', 'content_hash',
];
protected function casts(): array
@@ -18,6 +19,14 @@ class Note extends Model
];
}
/**
* @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);