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.

Document.php 1.7KB

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