Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Bill.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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\BillStatus;
  7. use App\Models\Banking\Payment;
  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\MorphMany;
  13. class Bill extends Model
  14. {
  15. use Blamable;
  16. use CompanyOwned;
  17. use HasFactory;
  18. protected $table = 'bills';
  19. protected $fillable = [
  20. 'company_id',
  21. 'vendor_id',
  22. 'bill_number',
  23. 'order_number',
  24. 'date',
  25. 'due_date',
  26. 'status',
  27. 'currency_code',
  28. 'subtotal',
  29. 'tax_total',
  30. 'discount_total',
  31. 'total',
  32. 'amount_paid',
  33. 'created_by',
  34. 'updated_by',
  35. ];
  36. protected $casts = [
  37. 'date' => 'date',
  38. 'due_date' => 'date',
  39. 'status' => BillStatus::class,
  40. 'subtotal' => MoneyCast::class,
  41. 'tax_total' => MoneyCast::class,
  42. 'discount_total' => MoneyCast::class,
  43. 'total' => MoneyCast::class,
  44. 'amount_paid' => MoneyCast::class,
  45. 'amount_due' => MoneyCast::class,
  46. ];
  47. public function vendor(): BelongsTo
  48. {
  49. return $this->belongsTo(Vendor::class);
  50. }
  51. public function lineItems(): MorphMany
  52. {
  53. return $this->morphMany(DocumentLineItem::class, 'documentable');
  54. }
  55. public function payments(): MorphMany
  56. {
  57. return $this->morphMany(Payment::class, 'payable');
  58. }
  59. }