ldc-gen-game-web/app/Models/InstantWin.php

66 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class InstantWin extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = ['prize'];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'appear_date' => 'datetime',
'done' => 'bool'
];
// * RELATIONSHIPS
/**
* BelongsTo Prize relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function prize()
{
return $this->belongsTo(Prize::class, 'prize_id');
}
/**
* One to one relation participation
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function participation()
{
return $this->belongsTo(Participation::class);
}
// * Methods
/**
* Get won attribute
*
* @return boolean
*/
public function getWonAttribute(): bool
{
return $this->participation()->exists();
}
}