-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathWorkout.php
More file actions
54 lines (42 loc) · 1.15 KB
/
Workout.php
File metadata and controls
54 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace App\Models;
use Awobaz\Compoships\Compoships;
use Awobaz\Compoships\Database\Eloquent\Relations\HasOne;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Workout extends Model
{
use HasFactory, Compoships;
protected $guarded = [];
public function scopeCompleted()
{
return $this->update([
'is_completed' => 1,
'score' => 100,
'date_get_score' => Carbon::now()->format("Y-m-d")
]);
}
public function Sessionable():BelongsTo
{
return $this->belongsTo(Sessionable::class);
}
public function Session(): BelongsTo
{
return $this->belongsTo(Session::class);
}
public function WorkOutQuiz():HasMany
{
return $this->hasMany(WorkoutQuizLog::class);
}
public function User(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function Participant(): HasOne
{
return $this->hasOne(Participant::class);
}
}