refactor(usermanagement): tidy up User model code structure and improve attribute casting
This commit is contained in:
@@ -1,16 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Usermanagement\Models;
|
namespace Modules\Usermanagement\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Modules\Basicdata\Models\Branch;
|
use Modules\Basicdata\Models\Branch;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Modules\Adk\Models\Appointment;
|
||||||
use Mattiverse\Userstamps\Traits\Userstamps;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
use Mattiverse\Userstamps\Traits\Userstamps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class User
|
* Class User
|
||||||
*
|
*
|
||||||
* This class extends the Laravel's Authenticatable class and represents a User in the application.
|
* This class extends the Laravel's Authenticatable class and represents a User in the application.
|
||||||
@@ -23,8 +24,8 @@
|
|||||||
*
|
*
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
*/
|
*/
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use HasFactory, Notifiable, Userstamps, HasRoles, softDeletes;
|
use HasFactory, Notifiable, Userstamps, HasRoles, softDeletes;
|
||||||
|
|
||||||
protected $guard_name = ['web'];
|
protected $guard_name = ['web'];
|
||||||
@@ -68,8 +69,7 @@
|
|||||||
*
|
*
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
protected function casts()
|
protected function casts(): array
|
||||||
: array
|
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
@@ -78,7 +78,8 @@
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function branch(){
|
public function branch()
|
||||||
|
{
|
||||||
return $this->belongsTo(Branch::class);
|
return $this->belongsTo(Branch::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,4 +92,14 @@
|
|||||||
{
|
{
|
||||||
return \Modules\Usermanagement\Database\Factories\UserFactory::new();
|
return \Modules\Usermanagement\Database\Factories\UserFactory::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the appointments for the User
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function appointments()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Appointment::class, 'admin_id');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user