File size: 1,530 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <?php
namespace App\Models\Chatbot;
use App\Models\User;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Chatbot extends Model
{
protected $table = 'chatbot';
protected $fillable = [
'user_id',
'title',
'role',
'model',
'first_message',
'instructions',
'chatbot_interests',
'image',
'width',
'height',
'color',
'status',
];
public function imageUrl(): Attribute
{
return new Attribute(
get: fn () => asset('uploads/' . $this->image)
);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
public function data(): HasMany
{
return $this->hasMany(ChatbotData::class, 'chatbot_id');
}
public function trainingData(): HasMany
{
return $this->hasMany(ChatbotData::class, 'chatbot_id', 'id')
->where('status', 'trained');
}
public function domains(): HasMany
{
return $this->hasMany(Domain::class);
}
public function canNewDomainAdd(): bool
{
if ($this->domains->isEmpty()) {
return true;
}
return $this->supportsMultipleDomains();
}
public function supportsMultipleDomains(): bool
{
return true; // @todo: implement this
}
}
|