init
This commit is contained in:
86
app/Models/AiModel.php
Normal file
86
app/Models/AiModel.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\EntityStatus;
|
||||
use App\Enums\SourceLevel;
|
||||
use App\Models\Concerns\HasPublicationScope;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class AiModel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasPublicationScope;
|
||||
|
||||
protected $table = 'ai_models';
|
||||
|
||||
protected $fillable = [
|
||||
'category_id',
|
||||
'source_id',
|
||||
'name',
|
||||
'slug',
|
||||
'provider',
|
||||
'summary',
|
||||
'description',
|
||||
'modality',
|
||||
'context_window',
|
||||
'price_input',
|
||||
'price_output',
|
||||
'deployment_mode',
|
||||
'effectiveness_score',
|
||||
'price_score',
|
||||
'speed_score',
|
||||
'total_score',
|
||||
'source_level',
|
||||
'last_verified_at',
|
||||
'status',
|
||||
'is_stale',
|
||||
'stale_note',
|
||||
'alternative_model_id',
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'h1',
|
||||
'canonical_url',
|
||||
'published_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'price_input' => 'decimal:6',
|
||||
'price_output' => 'decimal:6',
|
||||
'last_verified_at' => 'datetime',
|
||||
'published_at' => 'datetime',
|
||||
'is_stale' => 'boolean',
|
||||
'source_level' => SourceLevel::class,
|
||||
'status' => EntityStatus::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function source(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Source::class);
|
||||
}
|
||||
|
||||
public function alternative(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'alternative_model_id');
|
||||
}
|
||||
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class, 'entity_tag_maps', 'entity_id', 'tag_id')
|
||||
->wherePivot('entity_type', self::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user