12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
-
- namespace App\Models\Accounting;
-
- use App\Casts\DocumentMoneyCast;
- use App\Concerns\CompanyOwned;
- use App\Enums\Accounting\BudgetIntervalType;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
-
- class BudgetAllocation extends Model
- {
- use CompanyOwned;
- use HasFactory;
-
- protected $fillable = [
- 'company_id',
- 'budget_item_id',
- 'period',
- 'interval_type',
- 'start_date',
- 'end_date',
- 'amount',
- ];
-
- protected $casts = [
- 'start_date' => 'date',
- 'end_date' => 'date',
- 'interval_type' => BudgetIntervalType::class,
- 'amount' => DocumentMoneyCast::class,
- ];
-
- public function budgetItem(): BelongsTo
- {
- return $this->belongsTo(BudgetItem::class);
- }
-
- public function isCurrentPeriod(): bool
- {
- return now()->between($this->start_date, $this->end_date);
- }
- }
|