feat: add insight timer

This commit is contained in:
2026-06-03 00:55:40 +03:30
parent 82164f691f
commit 6f01c783fd
13 changed files with 599 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BackgroundSound extends Model
{
protected $fillable = ['name', 'sound_path', 'image_path', 'order', 'is_active'];
protected $casts = [
'is_active' => 'boolean',
'order' => 'integer',
];
protected $appends = ['sound_url', 'image_url'];
public function getSoundUrlAttribute(): ?string
{
return $this->sound_path ? asset('storage/' . $this->sound_path) : null;
}
public function getImageUrlAttribute(): ?string
{
return $this->image_path ? asset('storage/' . $this->image_path) : null;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BellSound extends Model
{
protected $fillable = ['name', 'sound_path', 'image_path', 'order', 'is_active'];
protected $casts = [
'is_active' => 'boolean',
'order' => 'integer',
];
protected $appends = ['sound_url', 'image_url'];
public function getSoundUrlAttribute(): ?string
{
return $this->sound_path ? asset('storage/' . $this->sound_path) : null;
}
public function getImageUrlAttribute(): ?string
{
return $this->image_path ? asset('storage/' . $this->image_path) : null;
}
}
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class TimerPreset extends Model
{
protected $fillable = [
'user_id',
'name',
'duration_seconds',
'start_bell_id',
'end_bell_id',
'interval_bell_id',
'interval_seconds',
'interval_repeat',
'background_sound_id',
'background_image_id',
'volume',
];
protected $casts = [
'duration_seconds' => 'integer',
'interval_seconds' => 'integer',
'interval_repeat' => 'integer',
'volume' => 'integer',
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function startBell(): BelongsTo
{
return $this->belongsTo(BellSound::class, 'start_bell_id');
}
public function endBell(): BelongsTo
{
return $this->belongsTo(BellSound::class, 'end_bell_id');
}
public function intervalBell(): BelongsTo
{
return $this->belongsTo(BellSound::class, 'interval_bell_id');
}
public function backgroundSound(): BelongsTo
{
return $this->belongsTo(BackgroundSound::class, 'background_sound_id');
}
public function backgroundImage(): BelongsTo
{
return $this->belongsTo(Image::class, 'background_image_id');
}
// Eager-load set for returning a fully-resolved preset to the front.
public const RELATIONS = [
'startBell',
'endBell',
'intervalBell',
'backgroundSound',
'backgroundImage',
];
}