104 lines
2.2 KiB
PHP
104 lines
2.2 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',
|
|
'group',
|
|
'mov_uuid',
|
|
'webm_uuid',
|
|
'gif_uuid',
|
|
'webp_uuid',
|
|
'mov_url',
|
|
'webm_url',
|
|
'gif_url',
|
|
'webp_url',
|
|
'embedding',
|
|
'action_keywords',
|
|
'emotion_keywords',
|
|
'misc_keywords',
|
|
'image_hash',
|
|
];
|
|
|
|
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',
|
|
'image_hash',
|
|
];
|
|
|
|
protected $appends = [
|
|
'ids',
|
|
];
|
|
|
|
protected function ids(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn ($value, $attributes) => hashids_encode($attributes['id']),
|
|
);
|
|
}
|
|
}
|