Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AccountHistory.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Models\History;
  3. use App\Casts\CurrencyRateCast;
  4. use App\Casts\MoneyCast;
  5. use App\Models\Banking\Account;
  6. use App\Models\Setting\Currency;
  7. use Illuminate\Database\Eloquent\Factories\HasFactory;
  8. use Illuminate\Database\Eloquent\Model;
  9. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  10. use Wallo\FilamentCompanies\FilamentCompanies;
  11. class AccountHistory extends Model
  12. {
  13. use HasFactory;
  14. protected $table = 'account_histories';
  15. protected $fillable = [
  16. 'company_id',
  17. 'account_id',
  18. 'type',
  19. 'name',
  20. 'number',
  21. 'currency_code',
  22. 'opening_balance',
  23. 'balance',
  24. 'exchange_rate',
  25. 'status',
  26. 'actions',
  27. 'description',
  28. 'enabled',
  29. 'changed_by',
  30. ];
  31. protected $casts = [
  32. 'enabled' => 'boolean',
  33. 'opening_balance' => MoneyCast::class,
  34. 'balance' => MoneyCast::class,
  35. 'exchange_rate' => CurrencyRateCast::class,
  36. 'actions' => 'array',
  37. ];
  38. public function company(): BelongsTo
  39. {
  40. return $this->belongsTo(FilamentCompanies::companyModel(), 'company_id');
  41. }
  42. public function account(): BelongsTo
  43. {
  44. return $this->belongsTo(Account::class, 'account_id');
  45. }
  46. public function currency(): BelongsTo
  47. {
  48. return $this->belongsTo(Currency::class, 'currency_code', 'code');
  49. }
  50. public function changedBy(): BelongsTo
  51. {
  52. return $this->belongsTo(FilamentCompanies::userModel(), 'changed_by');
  53. }
  54. }