first commit

This commit is contained in:
ct
2025-05-28 12:59:01 +08:00
commit 21526508b1
230 changed files with 60411 additions and 0 deletions

75
app/Models/Media.php Normal file
View File

@@ -0,0 +1,75 @@
<?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 Illuminate\Support\Facades\Storage;
/**
* Class Media
*
* @property int $id
* @property uuid|null $uuid
* @property int $media_collection_id
* @property int|null $user_id
* @property string $media_type
* @property string $media_source
* @property string $media_provider
* @property string $name
* @property string $mime_type
* @property string $file_name
* @property string $file_path
* @property string $disk
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property MediaCollection $media_collection
*/
class Media extends Model
{
use SoftDeletes;
protected $table = 'medias';
protected $casts = [
'media_collection_id' => 'int',
'user_id' => 'int',
];
protected $fillable = [
'uuid',
'media_collection_id',
'user_id',
'media_type',
'media_source',
'media_provider',
'mime_type',
'file_name',
'file_path',
'disk',
];
protected $appends = [
'media_url',
];
public function media_collection()
{
return $this->belongsTo(MediaCollection::class);
}
protected function mediaUrl(): Attribute
{
return Attribute::make(
get: function ($value, $attributes) {
return Storage::disk($attributes['disk'])->url($attributes['file_path'].$attributes['file_name']);
}
);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class MediaCollection
*
* @property int $id
* @property string $key
* @property string $name
* @property string $description
* @property bool $is_system
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Collection|Media[] $media
*/
class MediaCollection extends Model
{
protected $table = 'media_collections';
protected $casts = [
'is_system' => 'bool',
];
protected $fillable = [
'key',
'name',
'description',
'is_system',
];
public function media()
{
return $this->hasMany(Media::class);
}
}

62
app/Models/User.php Normal file
View File

@@ -0,0 +1,62 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Str;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasApiTokens, HasFactory, Notifiable, SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'email',
'password',
'uuid',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
'id',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
/**
* The "booted" method of the model.
*/
protected static function booted(): void
{
static::creating(function ($model) {
$model->uuid = $model->uuid ?? (string) Str::uuid();
});
}
}

80
app/Models/Video.php Normal file
View File

@@ -0,0 +1,80 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Str;
/**
* Class Video
*
* @property int $id
* @property string|null $external_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Collection|VideoRender[] $video_renders
*/
class Video extends Model
{
use SoftDeletes;
protected $table = 'videos';
protected $casts = [
'width' => 'int',
'height' => 'int',
'payload' => 'object',
'render_settings' => 'object',
];
protected $fillable = [
'external_id',
'content_type',
'width',
'height',
'aspect_ratio',
'payload',
'render_settings',
];
protected $hidden = [
'id',
];
public function video_renders()
{
return $this->hasMany(VideoRender::class)->orderBy('id', 'DESC');
}
public function video_captions()
{
return $this->hasMany(VideoCaption::class)->orderBy('time', 'ASC');
}
public function video_elements()
{
return $this->hasMany(VideoElement::class)->orderBy('time', 'ASC');
}
public function latest_render()
{
return $this->hasOne(VideoRender::class)->latest();
}
/**
* The "booted" method of the model.
*/
protected static function booted(): void
{
static::creating(function ($model) {
$model->uuid = $model->uuid ?? (string) Str::uuid();
});
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class VideoCaption
*
* @property int $id
* @property int $video_id
* @property float $time
* @property float $duration
* @property string $text
* @property string $parameters
* @property string $payload
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property Video $video
*/
class VideoCaption extends Model
{
use SoftDeletes;
protected $table = 'video_captions';
protected $casts = [
'video_id' => 'int',
'time' => 'float',
'duration' => 'float',
'parameters' => 'object',
'words' => 'object',
];
protected $fillable = [
'video_id',
'time',
'duration',
'text',
'parameters',
'words',
];
public function video()
{
return $this->belongsTo(Video::class);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class VideoElement
*
* @property int $id
* @property string|null $original_asset_url
* @property uuid|null $asset_uuid
* @property string|null $asset_url
* @property string $type
* @property float $time
* @property int $track
* @property float $duration
* @property string $parameters
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*/
class VideoElement extends Model
{
use SoftDeletes;
protected $table = 'video_elements';
protected $casts = [
'time' => 'float',
'track' => 'int',
'duration' => 'float',
'parameters' => 'object',
];
protected $fillable = [
'parent_element_id',
'external_reference',
'asset_hash',
'original_asset_url',
'asset_uuid',
'asset_url',
'type',
'time',
'track',
'duration',
'parameters',
];
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Str;
/**
* Class VideoRender
*
* @property int $id
* @property uuid $uuid
* @property string|null $external_id
* @property int|null $video_id
* @property int|null $user_id
* @property string $payload
* @property string $status
* @property Carbon|null $processing_started_at
* @property Carbon|null $processing_finished_at
* @property uuid|null $completed_video_uuid
* @property string|null $completed_video_full_url
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Video|null $video
* @property User|null $user
*/
class VideoRender extends Model
{
use SoftDeletes;
protected $table = 'video_renders';
protected $casts = [
'video_id' => 'int',
'user_id' => 'int',
'processing_started_at' => 'datetime',
'processing_finished_at' => 'datetime',
'payload' => 'object',
];
protected $fillable = [
'uuid',
'external_id',
'video_id',
'user_id',
'payload',
'status',
'processing_started_at',
'processing_finished_at',
'completed_video_uuid',
'completed_video_full_url',
];
protected $hidden = [
'id',
];
public function video()
{
return $this->belongsTo(Video::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
/**
* The "booted" method of the model.
*/
protected static function booted(): void
{
static::creating(function ($model) {
$model->uuid = $model->uuid ?? (string) Str::uuid();
});
}
}