blob: 1e96d61fd72d712e3bcf7262833e6d0412df97f4 (
plain) (
blame)
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
|
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Activity extends Model
{
use HasFactory;
protected $fillable = [
'name',
'description',
'date',
'teacher_id',
'group_id',
];
protected $casts = [
'date' => 'date',
];
/**
* Get the teacher that created this activity.
*/
public function teacher(): BelongsTo
{
return $this->belongsTo(Teacher::class);
}
/**
* Get the group for this activity.
*/
public function group(): BelongsTo
{
return $this->belongsTo(Group::class);
}
/**
* Get the students participating in this activity.
*/
public function students(): BelongsToMany
{
return $this->belongsToMany(Student::class, 'activity_student')
->withPivot('score', 'notes')
->withTimestamps();
}
}
|