37 lines
785 B
PHP
37 lines
785 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||
|
|
|
||
|
|
class Prompt extends Model
|
||
|
|
{
|
||
|
|
/** @use HasFactory<\Database\Factories\PromptFactory> */
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'name',
|
||
|
|
'description',
|
||
|
|
'body',
|
||
|
|
'is_favorite',
|
||
|
|
'usage_count',
|
||
|
|
'last_used_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected function casts(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'is_favorite' => 'boolean',
|
||
|
|
'usage_count' => 'integer',
|
||
|
|
'last_used_at' => 'datetime',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function tags(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Tag::class)->orderBy('tags.name');
|
||
|
|
}
|
||
|
|
}
|