| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | 
							- <?php
 - 
 - namespace App\Models\Accounting;
 - 
 - use App\Casts\MoneyCast;
 - use App\Concerns\Blamable;
 - use App\Concerns\CompanyOwned;
 - use App\Enums\Accounting\AdjustmentCategory;
 - use App\Enums\Accounting\AdjustmentType;
 - use App\Models\Common\Offering;
 - use App\Observers\DocumentLineItemObserver;
 - use Illuminate\Database\Eloquent\Attributes\ObservedBy;
 - use Illuminate\Database\Eloquent\Factories\HasFactory;
 - use Illuminate\Database\Eloquent\Model;
 - use Illuminate\Database\Eloquent\Relations\BelongsTo;
 - use Illuminate\Database\Eloquent\Relations\MorphToMany;
 - 
 - #[ObservedBy(DocumentLineItemObserver::class)]
 - class DocumentLineItem extends Model
 - {
 -     use Blamable;
 -     use CompanyOwned;
 -     use HasFactory;
 - 
 -     protected $table = 'document_line_items';
 - 
 -     protected $fillable = [
 -         'company_id',
 -         'document_id',
 -         'offering_id',
 -         'description',
 -         'quantity',
 -         'unit_price',
 -         'total',
 -         'tax_total',
 -         'discount_total',
 -         'created_by',
 -         'updated_by',
 -     ];
 - 
 -     protected $casts = [
 -         'unit_price' => MoneyCast::class,
 -         'total' => MoneyCast::class,
 -         'tax_total' => MoneyCast::class,
 -         'discount_total' => MoneyCast::class,
 -     ];
 - 
 -     public function document(): BelongsTo
 -     {
 -         return $this->belongsTo(Document::class);
 -     }
 - 
 -     public function offering(): BelongsTo
 -     {
 -         return $this->belongsTo(Offering::class);
 -     }
 - 
 -     public function adjustments(): MorphToMany
 -     {
 -         return $this->morphToMany(Adjustment::class, 'adjustmentable', 'adjustmentables');
 -     }
 - 
 -     public function salesTaxes(): MorphToMany
 -     {
 -         return $this->adjustments()->where('category', AdjustmentCategory::Tax)->where('type', AdjustmentType::Sales);
 -     }
 - 
 -     public function salesDiscounts(): MorphToMany
 -     {
 -         return $this->adjustments()->where('category', AdjustmentCategory::Discount)->where('type', AdjustmentType::Sales);
 -     }
 - 
 -     public function taxes(): MorphToMany
 -     {
 -         return $this->adjustments()->where('category', AdjustmentCategory::Tax);
 -     }
 - 
 -     public function discounts(): MorphToMany
 -     {
 -         return $this->adjustments()->where('category', AdjustmentCategory::Discount);
 -     }
 - }
 
 
  |