feat: add scene settings feature
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Scene extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'image_path', 'video_path', 'sound_path', 'order', 'is_active'];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
protected $appends = ['image_url', 'video_url', 'sound_url', 'has_video'];
|
||||
|
||||
public function getImageUrlAttribute(): ?string
|
||||
{
|
||||
return $this->image_path ? asset('storage/' . $this->image_path) : null;
|
||||
}
|
||||
|
||||
public function getVideoUrlAttribute(): ?string
|
||||
{
|
||||
return $this->video_path ? asset('storage/' . $this->video_path) : null;
|
||||
}
|
||||
|
||||
public function getSoundUrlAttribute(): ?string
|
||||
{
|
||||
return $this->sound_path ? asset('storage/' . $this->sound_path) : null;
|
||||
}
|
||||
|
||||
// Whether this scene can be shown as a video (the "تبدیل صحنه به ویدیو" toggle).
|
||||
public function getHasVideoAttribute(): bool
|
||||
{
|
||||
return !empty($this->video_path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class UserSceneSetting extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'active_scene_id',
|
||||
'scene_volume',
|
||||
'background_play_seconds',
|
||||
'video_enabled',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'scene_volume' => 'integer',
|
||||
'background_play_seconds' => 'integer',
|
||||
'video_enabled' => 'boolean',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function activeScene(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Scene::class, 'active_scene_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user