| Server IP : 77.68.25.176 / Your IP : 216.73.216.25 Web Server : Apache System : Linux plesk 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64 User : dwp ( 10001) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/dazzlingwebplanet.co.uk/tap2teach.dazzlingwebplanet.com/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Authenticatable implements JWTSubject
{
use SoftDeletes, Notifiable;
public $table = 'users';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $dates = ['deleted_at'];
/**
* The attributes that are mass assignable.
*
* @var array
*/
public $fillable = [
'name',
'email',
'email_verified_at',
'password',
'remember_token'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
'name' => 'string',
'email' => 'string',
'email_verified_at' => 'datetime',
'password' => 'string',
'remember_token' => 'string'
];
public static $rules = [
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'email' => 'required|string|max:255',
'email_verified_at' => 'nullable',
'password' => 'nullable',
'remember_token' => 'nullable|string|max:100',
'created_at' => 'nullable',
'updated_at' => 'nullable'
];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
$user['user_id'] = $this->id;
$user['name'] = $this->name;
$user['email'] = $this->email;
$user_details = $this->user_details($this->id);
if (!empty($user_details)) {
$user['title'] = $user_details->title;
$user['first_name'] = $user_details->first_name;
$user['last_name'] = $user_details->last_name;
$user['date_of_birth'] = $user_details->date_of_birth;
$user['contact_number'] = $user_details->contact_number;
$user['country_code'] = $user_details->country_code;
$user['user_type'] = $user_details->user_type;
$user['age'] = $user_details->age;
$user['is_parent'] = $user_details->is_parent;
$user['status'] = $user_details->status;
} else {
$user['user_type'] = null;
}
return $user;
}
public function user_details($user_id)
{
$user_details = UserDetail::where('user_id', $user_id)->first();
return $user_details;
}
public function parent($user_id)
{
return ParentsDetails::where('user_id', $user_id)->first();
}
}