You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Adjustment.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Models\Accounting;
  3. use App\Casts\RateCast;
  4. use App\Concerns\Blamable;
  5. use App\Concerns\CompanyOwned;
  6. use App\Concerns\HasDefault;
  7. use App\Enums\Accounting\AdjustmentCategory;
  8. use App\Enums\Accounting\AdjustmentComputation;
  9. use App\Enums\Accounting\AdjustmentScope;
  10. use App\Enums\Accounting\AdjustmentType;
  11. use Database\Factories\Accounting\AdjustmentFactory;
  12. use Illuminate\Database\Eloquent\Factories\Factory;
  13. use Illuminate\Database\Eloquent\Factories\HasFactory;
  14. use Illuminate\Database\Eloquent\Model;
  15. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  16. use Illuminate\Database\Eloquent\Relations\MorphTo;
  17. class Adjustment extends Model
  18. {
  19. use Blamable;
  20. use CompanyOwned;
  21. use HasDefault;
  22. use HasFactory;
  23. protected $table = 'adjustments';
  24. protected $fillable = [
  25. 'company_id',
  26. 'account_id',
  27. 'category',
  28. 'type',
  29. 'rate',
  30. 'computation',
  31. 'scope',
  32. 'start_date',
  33. 'end_date',
  34. 'enabled',
  35. 'created_by',
  36. 'updated_by',
  37. ];
  38. protected $casts = [
  39. 'category' => AdjustmentCategory::class,
  40. 'type' => AdjustmentType::class,
  41. 'rate' => RateCast::class,
  42. 'computation' => AdjustmentComputation::class,
  43. 'scope' => AdjustmentScope::class,
  44. 'start_date' => 'datetime',
  45. 'end_date' => 'datetime',
  46. 'enabled' => 'boolean',
  47. ];
  48. public function account(): BelongsTo
  49. {
  50. return $this->belongsTo(Account::class, 'account_id');
  51. }
  52. public function adjustmentables(): MorphTo
  53. {
  54. return $this->morphTo();
  55. }
  56. protected static function newFactory(): Factory
  57. {
  58. return AdjustmentFactory::new();
  59. }
  60. }