Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Schedule | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| activeLocations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scheduleShifts | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| shifts | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| shiftType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Models\Shifts; |
| 6 | |
| 7 | use Carbon\Carbon; |
| 8 | use Engelsystem\Models\BaseModel; |
| 9 | use Engelsystem\Models\Location; |
| 10 | use Illuminate\Database\Eloquent\Collection; |
| 11 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 12 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 13 | use Illuminate\Database\Eloquent\Relations\BelongsToMany; |
| 14 | use Illuminate\Database\Eloquent\Relations\HasMany; |
| 15 | use Illuminate\Database\Eloquent\Relations\HasManyThrough; |
| 16 | use Illuminate\Database\Query\Builder as QueryBuilder; |
| 17 | |
| 18 | /** |
| 19 | * @property int $id |
| 20 | * @property string $name |
| 21 | * @property string $url |
| 22 | * @property int $shift_type |
| 23 | * @property bool $needed_from_shift_type |
| 24 | * @property int $minutes_before |
| 25 | * @property int $minutes_after |
| 26 | * @property Carbon|null $created_at |
| 27 | * @property Carbon|null $updated_at |
| 28 | * |
| 29 | * @property-read QueryBuilder|Location[] $activeLocations |
| 30 | * @property-read QueryBuilder|Collection|Shift[] $shifts |
| 31 | * @property-read QueryBuilder|Collection|ScheduleShift[] $scheduleShifts |
| 32 | * @property-read QueryBuilder|ShiftType $shiftType |
| 33 | * |
| 34 | * @method static QueryBuilder|Schedule[] whereId($value) |
| 35 | * @method static QueryBuilder|Schedule[] whereName($value) |
| 36 | * @method static QueryBuilder|Schedule[] whereUrl($value) |
| 37 | * @method static QueryBuilder|Schedule[] whereShiftType($value) |
| 38 | * @method static QueryBuilder|Schedule[] whereNeededFromShiftType($value) |
| 39 | * @method static QueryBuilder|Schedule[] whereMinutesBefore($value) |
| 40 | * @method static QueryBuilder|Schedule[] whereMinutesAfter($value) |
| 41 | * @method static QueryBuilder|Schedule[] whereCreatedAt($value) |
| 42 | * @method static QueryBuilder|Schedule[] whereUpdatedAt($value) |
| 43 | */ |
| 44 | class Schedule extends BaseModel |
| 45 | { |
| 46 | use HasFactory; |
| 47 | |
| 48 | /** @var bool enable timestamps */ |
| 49 | public $timestamps = true; // phpcs:ignore |
| 50 | |
| 51 | /** @var array Default attributes */ |
| 52 | protected $attributes = [ // phpcs:ignore |
| 53 | 'needed_from_shift_type' => false, |
| 54 | ]; |
| 55 | |
| 56 | /** @var array<string> */ |
| 57 | protected $casts = [ // phpcs:ignore |
| 58 | 'shift_type' => 'integer', |
| 59 | 'needed_from_shift_type' => 'boolean', |
| 60 | 'minutes_before' => 'integer', |
| 61 | 'minutes_after' => 'integer', |
| 62 | ]; |
| 63 | |
| 64 | /** @var array<string> Values that are mass assignable */ |
| 65 | protected $fillable = [ // phpcs:ignore |
| 66 | 'name', |
| 67 | 'url', |
| 68 | 'shift_type', |
| 69 | 'needed_from_shift_type', |
| 70 | 'minutes_before', |
| 71 | 'minutes_after', |
| 72 | ]; |
| 73 | |
| 74 | public function activeLocations(): BelongsToMany |
| 75 | { |
| 76 | return $this->belongsToMany(Location::class, 'schedule_locations'); |
| 77 | } |
| 78 | |
| 79 | public function scheduleShifts(): HasMany |
| 80 | { |
| 81 | return $this->hasMany(ScheduleShift::class); |
| 82 | } |
| 83 | |
| 84 | public function shifts(): HasManyThrough |
| 85 | { |
| 86 | return $this->hasManyThrough(Shift::class, ScheduleShift::class, 'schedule_id', 'id'); |
| 87 | } |
| 88 | |
| 89 | public function shiftType(): BelongsTo |
| 90 | { |
| 91 | return $this->belongsTo(ShiftType::class, 'shift_type', 'id'); |
| 92 | } |
| 93 | } |