41 lines
801 B
PHP
41 lines
801 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class SofaScoreTask extends Model
|
|
{
|
|
protected $appends = ['duration'];
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'mode',
|
|
'sport_id',
|
|
'day_from',
|
|
'day_to',
|
|
'is_active',
|
|
'compleated',
|
|
'run_repeatedly',
|
|
'run_slow',
|
|
'last_start',
|
|
'last_end',
|
|
];
|
|
|
|
public function getDurationAttribute(): string
|
|
{
|
|
return Carbon::parse($this->last_start)->diff(Carbon::parse($this->last_end));
|
|
}
|
|
|
|
public function sport()
|
|
{
|
|
return $this->belongsTo(Sport::class);
|
|
}
|
|
|
|
public function sofa_score_task_tournaments()
|
|
{
|
|
return $this->hasMany(SofaScoreTaskTournament::class);
|
|
}
|
|
}
|