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

Document.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Models\Accounting;
  3. use App\Casts\MoneyCast;
  4. use App\Concerns\Blamable;
  5. use App\Concerns\CompanyOwned;
  6. use App\Enums\Accounting\DocumentType;
  7. use App\Models\Banking\Payment;
  8. use App\Models\Common\Client;
  9. use App\Models\Common\Vendor;
  10. use Illuminate\Database\Eloquent\Factories\HasFactory;
  11. use Illuminate\Database\Eloquent\Model;
  12. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  13. use Illuminate\Database\Eloquent\Relations\HasMany;
  14. class Document extends Model
  15. {
  16. use Blamable;
  17. use CompanyOwned;
  18. use HasFactory;
  19. protected $table = 'documents';
  20. protected $fillable = [
  21. 'company_id',
  22. 'client_id',
  23. 'vendor_id',
  24. 'type',
  25. 'logo',
  26. 'header',
  27. 'subheader',
  28. 'document_number',
  29. 'order_number',
  30. 'date',
  31. 'due_date',
  32. 'status',
  33. 'currency_code',
  34. 'subtotal',
  35. 'tax_total',
  36. 'discount_total',
  37. 'total',
  38. 'amount_paid',
  39. 'terms',
  40. 'footer',
  41. 'created_by',
  42. 'updated_by',
  43. ];
  44. protected $casts = [
  45. 'type' => DocumentType::class,
  46. 'date' => 'date',
  47. 'due_date' => 'date',
  48. 'subtotal' => MoneyCast::class,
  49. 'tax_total' => MoneyCast::class,
  50. 'discount_total' => MoneyCast::class,
  51. 'total' => MoneyCast::class,
  52. 'amount_paid' => MoneyCast::class,
  53. ];
  54. public function client(): BelongsTo
  55. {
  56. return $this->belongsTo(Client::class);
  57. }
  58. public function vendor(): BelongsTo
  59. {
  60. return $this->belongsTo(Vendor::class);
  61. }
  62. public function lineItems(): HasMany
  63. {
  64. return $this->hasMany(DocumentLineItem::class);
  65. }
  66. public function payments(): HasMany
  67. {
  68. return $this->hasMany(Payment::class);
  69. }
  70. }