mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-13 03:31:31 +00:00
updated streamline-setup v2
This commit is contained in:
Executable
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Streamline\Models;
|
||||
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use OwenIt\Auditing\Contracts\Auditable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
//use Laravel\Passport\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable implements Auditable {
|
||||
|
||||
use Notifiable;
|
||||
use HasRoles;
|
||||
use \OwenIt\Auditing\Auditable;
|
||||
|
||||
use SoftDeletes;
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'first_name', 'last_name', 'username', 'phone', 'position_id', 'email', 'photo', 'council_registration', 'willing_to_donate', 'last_donation_date', 'council_id', 'registration_number', 'expiry_date', 'password',
|
||||
'pin', 'blood_group_id', 'created_by', 'updated_by', 'last_seen'
|
||||
];
|
||||
public $timestamps = true;
|
||||
protected $rememberTokenName = false;
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token'
|
||||
];
|
||||
protected $casts = [
|
||||
'expiry_date' => 'datetime',
|
||||
'last_donation_date' => 'datetime'
|
||||
];
|
||||
|
||||
/*
|
||||
* Below are some mutators
|
||||
*/
|
||||
private string $first_name;
|
||||
private string $last_name;
|
||||
|
||||
public function setExpiryDateAttribute($expiry_date): void
|
||||
{
|
||||
$this->attributes['expiry_date'] = empty($expiry_date) ? NULL : Carbon::createFromFormat('d/m/Y', $expiry_date)->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function setLastDonationDateAttribute($last_donation_date): void
|
||||
{
|
||||
$this->attributes['last_donation_date'] = empty($last_donation_date) ? NULL : Carbon::createFromFormat('d/m/Y', $last_donation_date)->format('Y-m-d');
|
||||
}
|
||||
|
||||
/*
|
||||
* Accessors
|
||||
*/
|
||||
|
||||
public function getExpiryDateAttribute($expiry_date): string
|
||||
{
|
||||
return $expiry_date == NULL ? '' : Carbon::createFromFormat('Y-m-d', $expiry_date)->format('d/m/Y');
|
||||
}
|
||||
|
||||
public function getLastDonationDateAttribute($last_donation_date): string
|
||||
{
|
||||
//$last_donation_date == NULL ? '' : Carbon::createFromFormat('Y-m-d', $last_donation_date)->format('d/m/Y');
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function resolveId() {
|
||||
return Auth::check() ? Auth::user()->getAuthIdentifier() : null;
|
||||
}
|
||||
|
||||
public function passwordSecurity()
|
||||
{
|
||||
return $this->hasOne('Streamline\Models\PasswordSecurity');
|
||||
}
|
||||
|
||||
public function getFullNameAttribute(): string
|
||||
{
|
||||
return $this->first_name . ' ' . $this->last_name;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user