Car-Repairs-Shop/app/Models/Supplier.php
sackey e839d40a99
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
Initial commit
2025-07-30 17:15:50 +00:00

63 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Supplier extends Model
{
use HasFactory;
protected $fillable = [
'name',
'company_name',
'email',
'phone',
'website',
'address',
'city',
'state',
'zip_code',
'country',
'contact_person',
'payment_terms',
'account_number',
'tax_id',
'notes',
'is_active',
'rating',
];
protected $casts = [
'is_active' => 'boolean',
'rating' => 'decimal:1',
];
public function parts(): HasMany
{
return $this->hasMany(Part::class);
}
public function purchaseOrders(): HasMany
{
return $this->hasMany(PurchaseOrder::class);
}
public function stockMovements(): HasMany
{
return $this->hasMany(StockMovement::class);
}
public function getFullNameAttribute(): string
{
return $this->company_name ?: $this->name;
}
public function scopeActive($query)
{
return $query->where('is_active', true);
}
}