Files
compras/app/Models/Supplier.php
T
nala 4d42f083ce
tests / ci (push) Canceled after 0s
commit
2026-10-28 12:06:05 +02:00

40 lines
885 B
PHP

<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* @property int $id
* @property int $tenant_id
* @property int $created_by
* @property int|null $last_changed_by
* @property int $version
*/
class Supplier extends Model
{
use BelongsToTenant;
protected $guarded = ['id'];
protected $attributes = ['version' => 1];
protected function casts(): array
{
return ['blocked' => 'boolean', 'next_review' => 'date:Y-m-d'];
}
public function eligible(): bool
{
return $this->status === 'active' && ! $this->blocked && $this->next_review >= today();
}
/** @return HasMany<SupplierDocument, $this> */
public function documents(): HasMany
{
return $this->hasMany(SupplierDocument::class);
}
}