67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\SupplierFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Supplier extends Model
|
|
{
|
|
/** @use HasFactory<SupplierFactory> */
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'url',
|
|
'contact_person',
|
|
'email',
|
|
'phone',
|
|
'country_id',
|
|
'notes',
|
|
'active',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Country, $this>
|
|
*/
|
|
public function country(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Country::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<SupplierCategory, $this>
|
|
*/
|
|
public function supplierCategories(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
SupplierCategory::class,
|
|
'supplier_supplier_category',
|
|
'supplier_id',
|
|
'supplier_category_id'
|
|
)->withTimestamps();
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<PackagingItem, $this>
|
|
*/
|
|
public function packagingItems(): HasMany
|
|
{
|
|
return $this->hasMany(PackagingItem::class);
|
|
}
|
|
}
|