ldc-legaulois/app/Models/GoldenCrushGame.php
2026-09-25 16:25:31 +02:00

63 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
class GoldenCrushGame extends Model
{
use HasFactory;
protected $fillable = [
'customer_id',
'choice',
'ip_address',
];
protected $casts = [
'choice' => 'integer',
];
/**
* Relation with customer.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function customer()
{
return $this->belongsTo(Customer::class);
}
/**
* Check if already participate.
*
* @param int $customerId Customer id.
*/
public static function hasCustomerParticipated(int $customerId): bool
{
return self::where('customer_id', $customerId)->exists();
}
/**
* Get videos.
*
* @return array<string>
*/
public static function getVideos(): array
{
return [
[
'mp4' => Storage::url('videos/golden-crush/video1.mp4'),
'deco' => 'resources/assets/images/golden-crush/nuggets2.png',
'deco_position' => 'left',
],
[
'mp4' => Storage::url('videos/golden-crush/video2.mp4'),
'deco' => 'resources/assets/images/golden-crush/nuggets1.png',
'deco_position' => 'right',
],
];
}
}