5 use App\Events\ResultChanged;
6 use Illuminate\Database\Eloquent\Factories\HasFactory;
7 use Illuminate\Database\Eloquent\Model;
9 class Result extends Model
14 public function updateResult($time, $forfeit) {
16 $this->forfeit = $forfeit;
18 if ($this->wasChanged()) {
19 ResultChanged::dispatch($this);
23 public function updatePlacement($score, $placement) {
24 $this->score = $score;
25 $this->placement = $placement;
27 if ($this->wasChanged()) {
28 ResultChanged::dispatch($this);
33 public function round() {
34 return $this->belongsTo(Round::class);
37 public function participant() {
38 return $this->belongsTo(Participant::class);
41 public function getHasFinishedAttribute() {
42 return $this->time > 0 || $this->forfeit;
46 protected $appends = [
50 protected $fillable = [