102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use App\Models\Admin\manage_admin;
|
|
use App\Models\Admin\manage_module;
|
|
use App\Models\Admin\manage_admin_manage_module_link;
|
|
|
|
class User extends Authenticatable {
|
|
|
|
use HasApiTokens,
|
|
HasFactory,
|
|
Notifiable;
|
|
|
|
protected $table = 'iam_principal';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'id',
|
|
'first_name',
|
|
'last_name',
|
|
'email',
|
|
'email_verified_at',
|
|
'password',
|
|
'programs_xid',
|
|
'country_xid',
|
|
'start_date',
|
|
'duration',
|
|
'phone_number',
|
|
'gender',
|
|
'date_of_birth',
|
|
'address_line1',
|
|
'city',
|
|
'country',
|
|
'state',
|
|
'post_code',
|
|
'lang_level',
|
|
'hear_about_us',
|
|
'motivation_to_join_program',
|
|
'any_comment',
|
|
'created_at',
|
|
'updated_at'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
|
|
|
|
public function getPermissionGranted($id,$module){
|
|
// $id is used as authuser id
|
|
// $moudle is the slug of sidebar module
|
|
|
|
$isSubAdmin = manage_admin::where('id',$id)->where('is_admin',1)->first();
|
|
// 'is_admin',1 is for checking the login user is subadmin or not
|
|
|
|
if($isSubAdmin){
|
|
//search for module
|
|
$isModule = manage_module::where('slug',$module)->first();
|
|
if($isModule){
|
|
$isSubAdminModuleLink = manage_admin_manage_module_link::where('sub_admin_xid',$id)
|
|
->where('manage_modules_xid',$isModule->id)->first();
|
|
if($isSubAdminModuleLink){
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}else{
|
|
return false;
|
|
}
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|