Files
memefast/app/Models/MemeMedia.php
2025-06-20 13:03:52 +08:00

101 lines
2.1 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Pgvector\Laravel\HasNeighbors;
use Pgvector\Laravel\Vector;
use Spatie\Tags\HasTags;
/**
* Class MemeMedia
*
* @property int $id
* @property string $type
* @property string $sub_type
* @property string $name
* @property string $description
* @property string $keywords
* @property uuid $media_1_uuid
* @property uuid|null $media_2_uuid
* @property string $media_1_mime_type
* @property string|null $media_2_mime_type
* @property Vector|null $embedding
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
*/
class MemeMedia extends Model
{
use HasNeighbors, HasTags, SoftDeletes;
protected $table = 'meme_medias';
protected $casts = [
'embedding' => Vector::class,
'duration' => 'double',
'keywords' => 'array',
'is_enabled' => 'boolean',
'action_keywords' => 'array',
'emotion_keywords' => 'array',
'misc_keywords' => 'array',
];
protected $fillable = [
'type',
'sub_type',
'original_id',
'name',
'description',
'keywords',
'mov_uuid',
'webm_uuid',
'gif_uuid',
'webp_uuid',
'mov_url',
'webm_url',
'gif_url',
'webp_url',
'embedding',
'action_keywords',
'emotion_keywords',
'misc_keywords',
];
protected $hidden = [
'id',
'created_at',
'updated_at',
'deleted_at',
'type',
'sub_type',
'original_id',
'description',
'mov_uuid',
'webm_uuid',
'gif_uuid',
'webp_uuid',
// 'mov_url',
// 'webm_url',
'embedding',
];
protected $appends = [
'ids',
];
protected function ids(): Attribute
{
return Attribute::make(
get: fn ($value, $attributes) => hashids_encode($attributes['id']),
);
}
}