2024-07-23 15:22:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2024-07-23 16:40:56 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2024-07-23 15:22:09 +00:00
|
|
|
|
|
|
|
class ToolFunction extends Model
|
|
|
|
{
|
2024-07-23 16:40:56 +00:00
|
|
|
protected $fillable = [
|
|
|
|
'tool_id',
|
|
|
|
'name',
|
|
|
|
'description',
|
|
|
|
'parameters',
|
|
|
|
'required',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function tool(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Tool::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getParametersAttribute($value)
|
|
|
|
{
|
|
|
|
return json_decode($value, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredAttribute($value)
|
|
|
|
{
|
|
|
|
return json_decode($value, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setParametersAttribute($value): void
|
|
|
|
{
|
|
|
|
$this->attributes['parameters'] = json_encode($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRequiredAttribute($value): void
|
|
|
|
{
|
|
|
|
$this->attributes['required'] = json_encode($value);
|
|
|
|
}
|
2024-07-23 15:22:09 +00:00
|
|
|
}
|