add poker planing for students
This commit is contained in:
20
app/Models/EstimationRound.php
Normal file
20
app/Models/EstimationRound.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EstimationRound extends Model
|
||||
{
|
||||
protected $fillable = ['token', 'max_score', 'max_voters'];
|
||||
|
||||
public function votes()
|
||||
{
|
||||
return $this->hasMany(Vote::class);
|
||||
}
|
||||
|
||||
public function getAverageScoreAttribute()
|
||||
{
|
||||
return $this->votes->avg('score');
|
||||
}
|
||||
}
|
||||
15
app/Models/Vote.php
Normal file
15
app/Models/Vote.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Vote extends Model
|
||||
{
|
||||
protected $fillable = ['estimation_round_id', 'name', 'score'];
|
||||
|
||||
public function estimationRound()
|
||||
{
|
||||
return $this->belongsTo(EstimationRound::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user