@@ -0,0 +1,39 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user