42 lines
850 B
PHP
42 lines
850 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Participation extends Model
|
|
{
|
|
|
|
protected $table = "participation";
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\User', 'user_id');
|
|
}
|
|
|
|
public function code()
|
|
{
|
|
return $this->belongsTo('App\Models\Codes', 'code_unique_id');
|
|
}
|
|
|
|
public function code_ean()
|
|
{
|
|
return $this->belongsTo('App\Models\CodesEAN', 'code_ean_id');
|
|
}
|
|
|
|
public function instant_win()
|
|
{
|
|
return $this->hasOne('App\Models\InstantWin', 'participation_id');
|
|
}
|
|
|
|
public function reduction()
|
|
{
|
|
return $this->hasOne('App\Models\Reductions', 'reduction_id');
|
|
}
|
|
|
|
public function getCodeEanValueAttribute()
|
|
{
|
|
$code = CodesEAN::find($this->code_ean_id)->code;
|
|
return $code;
|
|
}
|
|
}
|