47 lines
1015 B
PHP
47 lines
1015 B
PHP
<?php
|
|
|
|
namespace App\Models\Fox;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class FoxMemoryNode extends Model
|
|
{
|
|
use HasUuids;
|
|
|
|
protected $table = 'fox_memory_nodes';
|
|
|
|
protected $fillable = [
|
|
'type',
|
|
'title',
|
|
'content',
|
|
'meta',
|
|
'confidence',
|
|
'weight',
|
|
'last_used_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'meta' => 'array',
|
|
'confidence' => 'float',
|
|
'weight' => 'integer',
|
|
'last_used_at' => 'datetime',
|
|
];
|
|
|
|
public function outgoingEdges(): HasMany
|
|
{
|
|
return $this->hasMany(FoxMemoryEdge::class, 'source_node_id');
|
|
}
|
|
|
|
public function incomingEdges(): HasMany
|
|
{
|
|
return $this->hasMany(FoxMemoryEdge::class, 'target_node_id');
|
|
}
|
|
|
|
public function touchUsed(): void
|
|
{
|
|
$this->update(['last_used_at' => now(), 'weight' => $this->weight + 1]);
|
|
}
|
|
}
|