Initial commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Wyposażenie z katalogów (legacy seg_equipments). Typ rozróżniany przez
|
||||
* EQU_TYPE_ID (sys_dictionaries): 13=kable (site206); 207/208 dołożą kolejne.
|
||||
* Database-first na bazie `softspm`.
|
||||
*/
|
||||
class Equipment extends Model
|
||||
{
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'seg_equipments';
|
||||
protected $primaryKey = 'EQU_ID';
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
|
||||
public function manufacturer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Manufacturer::class, 'EQU_MCF_ID', 'MCF_ID');
|
||||
}
|
||||
|
||||
public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany(EquipmentFile::class, 'EQF_EQU_ID', 'EQU_ID');
|
||||
}
|
||||
|
||||
/** Tylko widoczne (EQU_STATUS='1', nieusunięte logicznie). */
|
||||
public function scopeVisible(Builder $q): Builder
|
||||
{
|
||||
return $q->where('EQU_STATUS', '1');
|
||||
}
|
||||
|
||||
/** Filtr po rodzaju wyposażenia (EQU_TYPE_ID). */
|
||||
public function scopeOfType(Builder $q, int $typeId): Builder
|
||||
{
|
||||
return $q->where('EQU_TYPE_ID', $typeId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user