1 | <?php |
||
2 | |||
3 | namespace App\Models; |
||
4 | |||
5 | use Backpack\CRUD\app\Models\Traits\CrudTrait; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | use Spatie\Activitylog\Traits\LogsActivity; |
||
8 | |||
9 | /** |
||
10 | * A RemoteEvent represents hours that do not have a specific date/time, but that should be taken into account in the teacher's total for the month or the period |
||
11 | * |
||
12 | * @mixin IdeHelperRemoteEvent |
||
13 | */ |
||
14 | class RemoteEvent extends Model |
||
15 | { |
||
16 | use CrudTrait; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
17 | use LogsActivity; |
||
18 | |||
19 | protected $guarded = ['id']; |
||
20 | |||
21 | protected static bool $logUnguarded = true; |
||
22 | |||
23 | public function teacher() |
||
24 | { |
||
25 | return $this->belongsTo(Teacher::class); |
||
26 | } |
||
27 | |||
28 | public function course() |
||
29 | { |
||
30 | return $this->belongsTo(Course::class); |
||
31 | } |
||
32 | |||
33 | public function period() |
||
34 | { |
||
35 | return $this->belongsTo(Period::class); |
||
36 | } |
||
37 | |||
38 | /** we store the time volume in seconds */ |
||
39 | public function getWorkedHoursAttribute($value) |
||
40 | { |
||
41 | return $value / 3600; |
||
42 | } |
||
43 | |||
44 | /** we store the time volume in seconds */ |
||
45 | public function setWorkedHoursAttribute($value) |
||
46 | { |
||
47 | $this->attributes['worked_hours'] = $value * 3600; |
||
48 | } |
||
49 | } |
||
50 |