'integer', 'user_id' => 'integer', 'activity_fill' => 'integer', 'mouse_fill' => 'integer', 'keyboard_fill' => 'integer', 'is_manual' => 'boolean', 'location' => Point::class, ]; /** * @var array */ protected $dates = [ 'start_at', 'end_at', 'created_at', 'updated_at', 'deleted_at', ]; protected $appends = ['has_screenshot']; /** * Override parent boot and Call deleting event * * @return void */ protected static function boot(): void { parent::boot(); static::addGlobalScope(new TimeIntervalAccessScope); } public function task(): BelongsTo { return $this->belongsTo(Task::class, 'task_id')->withoutGlobalScopes(); } public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } public function properties(): MorphMany { return $this->morphMany(Property::class, 'entity'); } public function hasScreenshot(): Attribute { return Attribute::make( get: static fn ($value) => !$value || Storage::exists( app(ScreenshotService::class)->getScreenshotPath($value['id']) ) )->shouldCache(); } public function location(): Attribute { return Attribute::make( get: static fn ($value) => $value ? ['lat' => $value->latitude, 'lng' => $value->longitude] : null, set: static fn ($value) => $value ? new Point($value['lat'], $value['lng']) : null, )->shouldCache(); } public function apps(): HasMany { return $this->hasMany(TrackedApplication::class, 'time_interval_id'); } }