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