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;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class LoginLog extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'ip_address',
'user_agent',
'status'
];
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Menu extends Model
{
use HasFactory;
protected $fillable = ['title', 'url', 'icon', 'parent_id', 'order'];
public function parent()
{
return $this->belongsTo(Menu::class, 'parent_id');
}
public function children()
{
return $this->hasMany(Menu::class, 'parent_id')->orderBy('order');
}
}