update patch 1

This commit is contained in:
fiqhpratama
2024-12-02 01:18:34 +07:00
parent 453d9bb470
commit 25026b0a85
3380 changed files with 103529 additions and 363623 deletions
+78
View File
@@ -0,0 +1,78 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Traits\HasRoles;
class Admin extends Authenticatable
{
use Notifiable, HasRoles;
/**
* Set the default guard for this model.
*
* @var string
*/
protected $guard_name = 'admin';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public static function getpermissionGroups()
{
$permission_groups = DB::table('permissions')
->select('group_name as name')
->groupBy('group_name')
->get();
return $permission_groups;
}
public static function getpermissionsByGroupName($group_name)
{
$permissions = DB::table('permissions')
->select('name', 'id')
->where('group_name', $group_name)
->get();
return $permissions;
}
public static function roleHasPermissions($role, $permissions)
{
$hasPermission = true;
foreach ($permissions as $permission) {
if (!$role->hasPermissionTo($permission->name)) {
$hasPermission = false;
return $hasPermission;
}
}
return $hasPermission;
}
}