mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-09 14:18:59 +00:00
61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace FireflyIII\Models;
|
|
|
|
use FireflyIII\Casts\SeparateTimezoneCaster;
|
|
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
class PeriodStatistic extends Model
|
|
{
|
|
use ReturnsIntegerUserIdTrait;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
'start' => SeparateTimezoneCaster::class,
|
|
'end' => SeparateTimezoneCaster::class,
|
|
];
|
|
}
|
|
|
|
public function userGroup(): BelongsTo
|
|
{
|
|
return $this->belongsTo(UserGroup::class);
|
|
}
|
|
|
|
protected function count(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: static fn ($value) => (int)$value,
|
|
);
|
|
}
|
|
|
|
public function primaryStatable(): MorphTo
|
|
{
|
|
|
|
return $this->morphTo();
|
|
|
|
}
|
|
|
|
public function secondaryStatable(): MorphTo
|
|
{
|
|
|
|
return $this->morphTo();
|
|
|
|
}
|
|
|
|
public function tertiaryStatable(): MorphTo
|
|
{
|
|
|
|
return $this->morphTo();
|
|
|
|
}
|
|
}
|