first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Registration extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'phone',
|
||||
'total_score',
|
||||
];
|
||||
|
||||
/*
|
||||
|---------------------------
|
||||
| Relationships
|
||||
|---------------------------
|
||||
*/
|
||||
|
||||
// A student has many game sessions (daily plays)
|
||||
public function sessions()
|
||||
{
|
||||
return $this->hasMany(GameSession::class);
|
||||
}
|
||||
|
||||
// A student has many comments
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class);
|
||||
}
|
||||
|
||||
/*
|
||||
|---------------------------
|
||||
| Helper methods
|
||||
|---------------------------
|
||||
*/
|
||||
|
||||
// Check if student already played today
|
||||
public function playedToday(): bool
|
||||
{
|
||||
return $this->sessions()
|
||||
->whereDate('play_date', today())
|
||||
->whereHas('shots', fn($q) => $q->havingRaw('COUNT(*) >= 3'))
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user