mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Add table for period statistics, and see what happens re: performance.
This commit is contained in:
56
app/Models/PeriodStatistic.php
Normal file
56
app/Models/PeriodStatistic.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
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\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PeriodStatistic extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'date' => SeparateTimezoneCaster::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();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
}
|
Reference in New Issue
Block a user