| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 | 
							- <?php
 - 
 - namespace App\Models\Setting;
 - 
 - use App\Enums\{CategoryType, DiscountType, TaxType};
 - use App\Models\Banking\Account;
 - use App\Traits\{Blamable, CompanyOwned};
 - use Database\Factories\Setting\CompanyDefaultFactory;
 - use Illuminate\Database\Eloquent\Factories\{Factory, HasFactory};
 - use Illuminate\Database\Eloquent\Model;
 - use Illuminate\Database\Eloquent\Relations\BelongsTo;
 - use Wallo\FilamentCompanies\FilamentCompanies;
 - 
 - class CompanyDefault extends Model
 - {
 -     use Blamable;
 -     use CompanyOwned;
 -     use HasFactory;
 - 
 -     protected $table = 'company_defaults';
 - 
 -     protected $fillable = [
 -         'company_id',
 -         'account_id',
 -         'currency_code',
 -         'sales_tax_id',
 -         'purchase_tax_id',
 -         'sales_discount_id',
 -         'purchase_discount_id',
 -         'income_category_id',
 -         'expense_category_id',
 -         'created_by',
 -         'updated_by',
 -     ];
 - 
 -     public function company(): BelongsTo
 -     {
 -         return $this->belongsTo(FilamentCompanies::companyModel(), 'company_id');
 -     }
 - 
 -     public function account(): BelongsTo
 -     {
 -         return $this->belongsTo(Account::class, 'account_id');
 -     }
 - 
 -     public function currency(): BelongsTo
 -     {
 -         return $this->belongsTo(Currency::class, 'currency_code', 'code');
 -     }
 - 
 -     public function salesTax(): BelongsTo
 -     {
 -         return $this->belongsTo(Tax::class, 'sales_tax_id', 'id')
 -             ->where('type', TaxType::Sales);
 -     }
 - 
 -     public function purchaseTax(): BelongsTo
 -     {
 -         return $this->belongsTo(Tax::class, 'purchase_tax_id', 'id')
 -             ->where('type', TaxType::Purchase);
 -     }
 - 
 -     public function salesDiscount(): BelongsTo
 -     {
 -         return $this->belongsTo(Discount::class, 'sales_discount_id', 'id')
 -             ->where('type', DiscountType::Sales);
 -     }
 - 
 -     public function purchaseDiscount(): BelongsTo
 -     {
 -         return $this->belongsTo(Discount::class, 'purchase_discount_id', 'id')
 -             ->where('type', DiscountType::Purchase);
 -     }
 - 
 -     public function incomeCategory(): BelongsTo
 -     {
 -         return $this->belongsTo(Category::class, 'income_category_id', 'id')
 -             ->where('type', CategoryType::Income);
 -     }
 - 
 -     public function expenseCategory(): BelongsTo
 -     {
 -         return $this->belongsTo(Category::class, 'expense_category_id', 'id')
 -             ->where('type', CategoryType::Expense);
 -     }
 - 
 -     public function createdBy(): BelongsTo
 -     {
 -         return $this->belongsTo(FilamentCompanies::userModel(), 'created_by');
 -     }
 - 
 -     public function updatedBy(): BelongsTo
 -     {
 -         return $this->belongsTo(FilamentCompanies::userModel(), 'updated_by');
 -     }
 - 
 -     protected static function newFactory(): Factory
 -     {
 -         return CompanyDefaultFactory::new();
 -     }
 - }
 
 
  |