ldc-legaulois/app/Models/GoldenCrushGame.php

64 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2026-04-29 17:59:19 +02:00
<?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.
2026-05-06 17:11:13 +02:00
*
2026-04-29 17:59:19 +02:00
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function customer()
{
return $this->belongsTo(Customer::class);
}
/**
* Check if already participate.
*
2026-09-25 16:25:31 +02:00
* @param int $customerId Customer id.
2026-04-29 17:59:19 +02:00
*/
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 [
[
2026-09-25 16:25:31 +02:00
'mp4' => Storage::url('videos/golden-crush/video1.mp4'),
'deco' => 'resources/assets/images/golden-crush/nuggets2.png',
2026-04-29 17:59:19 +02:00
'deco_position' => 'left',
],
[
2026-09-25 16:25:31 +02:00
'mp4' => Storage::url('videos/golden-crush/video2.mp4'),
'deco' => 'resources/assets/images/golden-crush/nuggets1.png',
2026-04-29 17:59:19 +02:00
'deco_position' => 'right',
],
];
}
}