您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BudgetAllocation.php 998B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Models\Accounting;
  3. use App\Casts\DocumentMoneyCast;
  4. use App\Concerns\CompanyOwned;
  5. use App\Enums\Accounting\BudgetIntervalType;
  6. use Illuminate\Database\Eloquent\Factories\HasFactory;
  7. use Illuminate\Database\Eloquent\Model;
  8. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  9. class BudgetAllocation extends Model
  10. {
  11. use CompanyOwned;
  12. use HasFactory;
  13. protected $fillable = [
  14. 'company_id',
  15. 'budget_item_id',
  16. 'period',
  17. 'interval_type',
  18. 'start_date',
  19. 'end_date',
  20. 'amount',
  21. ];
  22. protected $casts = [
  23. 'start_date' => 'date',
  24. 'end_date' => 'date',
  25. 'interval_type' => BudgetIntervalType::class,
  26. 'amount' => DocumentMoneyCast::class,
  27. ];
  28. public function budgetItem(): BelongsTo
  29. {
  30. return $this->belongsTo(BudgetItem::class);
  31. }
  32. public function isCurrentPeriod(): bool
  33. {
  34. return now()->between($this->start_date, $this->end_date);
  35. }
  36. }