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

71 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Participation extends Model
{
2022-03-15 16:27:41 +01:00
// * RELATIONSHIPS
/**
2022-03-15 16:27:41 +01:00
* BelongsTo Customer relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
2022-03-15 16:27:41 +01:00
public function customer()
2021-08-18 17:08:02 +02:00
{
2022-03-15 16:27:41 +01:00
return $this->belongsTo(Customer::class);
}
/**
* BelongsTo Codes relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
2021-08-18 17:08:02 +02:00
public function code()
{
return $this->belongsTo(Code::class, 'code_unique_id');
}
/**
* BelongsTo CodesEAN relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function codeEan()
2021-08-18 17:08:02 +02:00
{
return $this->belongsTo(CodeEan::class);
}
/**
* One to one InstantWin relation
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function instantWin()
2021-08-18 17:08:02 +02:00
{
return $this->hasOne(InstantWin::class);
}
/**
* One to one Reduction relation
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
2021-08-18 17:08:02 +02:00
public function reduction()
{
return $this->hasOne(Reduction::class);
}
/**
* ean_code_value accessor
*
* @return integer|null
*/
2021-08-18 17:08:02 +02:00
public function getCodeEanValueAttribute()
{
return optional($this->codeEan)->code;
}
}