1 | <?php |
||
2 | |||
3 | namespace App\Judite\Models; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Model; |
||
6 | |||
7 | class Settings extends Model |
||
8 | { |
||
9 | /** |
||
10 | * The attributes that are mass assignable. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $fillable = [ |
||
15 | 'exchanges_start_at', |
||
16 | 'exchanges_end_at', |
||
17 | 'enrollments_start_at', |
||
18 | 'enrollments_end_at', |
||
19 | ]; |
||
20 | |||
21 | /** |
||
22 | * The attributes that should be mutated to dates. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $dates = [ |
||
27 | 'created_at', |
||
28 | 'updated_at', |
||
29 | 'exchanges_start_at', |
||
30 | 'exchanges_end_at', |
||
31 | 'enrollments_start_at', |
||
32 | 'enrollments_end_at', |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * Checks whether today's date is within the shift exchanging period. |
||
37 | * |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function withinExchangePeriod(): bool |
||
41 | { |
||
42 | if (is_null($this->exchanges_start_at) || is_null($this->exchanges_end_at)) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
43 | return false; |
||
44 | } |
||
45 | |||
46 | return $this->exchanges_start_at->isPast() && ! $this->exchanges_end_at->isPast(); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Checks whether today's date is within the course enrollment period. |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function withinEnrollmentPeriod(): bool |
||
55 | { |
||
56 | if (is_null($this->enrollments_start_at) || is_null($this->enrollments_end_at)) { |
||
0 ignored issues
–
show
|
|||
57 | return false; |
||
58 | } |
||
59 | |||
60 | return $this->enrollments_start_at->isPast() && ! $this->enrollments_end_at->isPast(); |
||
61 | } |
||
62 | } |
||
63 |