Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/** Silnik - katalog (legacy site204). Tabela seg_engines (database-first). */
|
||||
class Engine extends Model
|
||||
{
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'seg_engines';
|
||||
protected $primaryKey = 'ENG_ID';
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
|
||||
public function manufacturer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Manufacturer::class, 'ENG_MCF_ID', 'MCF_ID');
|
||||
}
|
||||
|
||||
/** Tylko widoczne (ENG_STATUS='1'). */
|
||||
public function scopeVisible(Builder $q): Builder
|
||||
{
|
||||
return $q->where('ENG_STATUS', '1');
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Załącznik wyposażenia (legacy seg_equipments_files) - plik trzymany jako BLOB
|
||||
* w bazie (EQF_FILE mediumblob). Rola pliku wynika z prefiksu MIME:
|
||||
* 'image/*' = zdjęcie, pozostałe (np. 'application/pdf') = dokumentacja.
|
||||
*/
|
||||
class EquipmentFile extends Model
|
||||
{
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'seg_equipments_files';
|
||||
protected $primaryKey = 'EQF_ID';
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
|
||||
/** Czy to plik graficzny (zdjęcie). */
|
||||
public function isImage(): bool
|
||||
{
|
||||
return str_starts_with(strtolower((string) $this->EQF_FILE_TYPE), 'image/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/** Producent - tabela seg_manufacturers. */
|
||||
class Manufacturer extends Model
|
||||
{
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'seg_manufacturers';
|
||||
protected $primaryKey = 'MCF_ID';
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Pompa - katalog (legacy site203). Tabela seg_pumps (database-first).
|
||||
* Uwaga: PUP_Q_N i krzywe PEP_X_PARAM trzymane ×60; w UI dzielimy /60 (m³/min).
|
||||
*/
|
||||
class Pump extends Model
|
||||
{
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'seg_pumps';
|
||||
protected $primaryKey = 'PUP_ID';
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
|
||||
public function manufacturer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Manufacturer::class, 'PUP_MCF_ID', 'MCF_ID');
|
||||
}
|
||||
|
||||
public function curvePoints(): HasMany
|
||||
{
|
||||
return $this->hasMany(PumpCurvePoint::class, 'PEP_PUP_ID', 'PUP_ID');
|
||||
}
|
||||
|
||||
/** Tylko widoczne (PUP_STATUS='1', nieusunięte logicznie). */
|
||||
public function scopeVisible(Builder $q): Builder
|
||||
{
|
||||
return $q->where('PUP_STATUS', '1');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Punkt krzywej pompy (Q-H lub Q-ETA) - tabela seg_pump_eng_param.
|
||||
* PEP_TYPE: 'H' | 'ETA'. PEP_X_PARAM trzymane ×60 (m³/min po /60).
|
||||
*/
|
||||
class PumpCurvePoint extends Model
|
||||
{
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'seg_pump_eng_param';
|
||||
protected $primaryKey = 'PEP_ID';
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
/**
|
||||
* Model użytkownika - DATABASE-FIRST na istniejącej tabeli `sys_users`
|
||||
* (baza operacyjna `softspm`). NIE zmieniamy schematu.
|
||||
*
|
||||
* Kolumny legacy (z func.php / index.php):
|
||||
* USR_ID - PK
|
||||
* USR_USERNAME - login
|
||||
* USR_PASSWORD - hash hasła (legacy: MD5, docelowo bcrypt - patrz LoginController)
|
||||
* USR_STATUS - '1' = aktywny
|
||||
* USR_PRT_ID - uczestnik/system (sys_participants)
|
||||
*/
|
||||
class User extends Authenticatable implements AuthenticatableContract
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
protected $connection = 'softspm';
|
||||
protected $table = 'sys_users';
|
||||
protected $primaryKey = 'USR_ID';
|
||||
|
||||
/** Tabela legacy nie ma created_at/updated_at. */
|
||||
public $timestamps = false;
|
||||
|
||||
/** Tabela legacy nie ma kolumny remember_token. */
|
||||
protected $rememberTokenName = '';
|
||||
|
||||
protected $hidden = [
|
||||
'USR_PASSWORD',
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Laravel Auth: która kolumna trzyma hash hasła.
|
||||
*/
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->USR_PASSWORD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wyłączamy mechanizm "remember me" - brak kolumny w schemacie legacy.
|
||||
*/
|
||||
public function getRememberToken()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setRememberToken($value)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user