Files
dimon8 d8a8759504 crud
2026-01-07 19:29:49 +00:00

42 lines
947 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AiTask extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'name',
'prompt_template',
'is_active',
];
protected $casts = [
'is_active' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
// Связь с пользователем (если шаблон пользовательский)
public function user()
{
return $this->belongsTo(User::class);
}
// Общие (глобальные) шаблоны — где user_id IS NULL
public function scopeGlobal($query)
{
return $query->whereNull('user_id');
}
// Активные шаблоны
public function scopeActive($query)
{
return $query->where('is_active', true);
}
}