*/ protected $casts = [ 'description' => 'string', 'start' => 'datetime', 'end' => 'datetime', 'billable' => 'bool', 'tags' => 'array', 'billable_rate' => 'int', ]; /** * The attributes that are computed. (f.e. for performance reasons) * These attributes can be regenerated at any time. * * @var string[] */ protected array $computed = [ 'billable_rate', ]; public function getBillableRateComputed(): ?int { return app(BillableRateService::class)->getBillableRateForTimeEntry($this); } public function getDuration(): ?CarbonInterval { return $this->end === null ? null : $this->start->diffAsCarbonInterval($this->end); } /** * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } /** * @return BelongsTo */ public function organization(): BelongsTo { return $this->belongsTo(Organization::class, 'organization_id'); } /** * @return BelongsTo */ public function project(): BelongsTo { return $this->belongsTo(Project::class, 'project_id'); } /** * @return BelongsTo */ public function task(): BelongsTo { return $this->belongsTo(Task::class, 'task_id'); } }