Files
aso/app/Models/OLDLMS/User.php
2023-03-12 18:50:07 +07:00

53 lines
1.2 KiB
PHP

<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model
{
use HasFactory, SoftDeletes;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tm_users';
protected $appends = [
'full_name',
];
protected function fullName(): Attribute
{
return Attribute::make(
get: function ($value) {
$names = [];
if (!empty($this->sFirstName)) {
array_push($names, $this->sFirstName);
}
if (!empty($this->sLastName)) {
array_push($names, $this->sLastName);
}
return implode(' ', $names);
}
);
}
public function detail()
{
return $this->hasOne(UserDetail::class, 'nIDUser', 'nID');
}
public function insurances()
{
return $this->hasMany(UserInsurance::class, 'nIDUser', 'nID');
}
}