mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
setup
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
use App\Http\Helpers\ImageHandel;
|
||||
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Admin extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasRoles, Notifiable;
|
||||
|
||||
protected $guard_name = 'admin';
|
||||
|
||||
protected $table = 'admins';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'pivot'
|
||||
];
|
||||
|
||||
protected $appends = ['hash_id', 'role_list', 'permission_list'];
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('admins', $this->id);
|
||||
}
|
||||
|
||||
public function getRoleListAttribute()
|
||||
{
|
||||
$role_list = $this->roles;
|
||||
unset($this->roles);
|
||||
return $role_list;
|
||||
}
|
||||
|
||||
public function getPermissionListAttribute()
|
||||
{
|
||||
$permission_list = $this->getAllPermissions()->pluck('name');
|
||||
unset($this->permissions);
|
||||
return $permission_list;
|
||||
}
|
||||
|
||||
public function getImgAttribute($value)
|
||||
{
|
||||
$file_info = [];
|
||||
$file_info = ImageHandel::getImgFullPath($value, 'person');
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AdminLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
protected $table = 'permissions';
|
||||
|
||||
protected $hidden = [
|
||||
'pivot'
|
||||
];
|
||||
|
||||
protected $appends = ['hash_id'];
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('permissions', $this->id);
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Spatie\Permission\Models\Role as SpatieRole;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
protected $table = 'roles';
|
||||
|
||||
protected $appends = ['hash_id', 'permission_list'];
|
||||
|
||||
protected $hidden = [
|
||||
'pivot'
|
||||
];
|
||||
|
||||
public function getAllPermissions()
|
||||
{
|
||||
return SpatieRole::find($this->id)->permissions;
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('roles', $this->id);
|
||||
}
|
||||
|
||||
public function getPermissionListAttribute()
|
||||
{
|
||||
$permission_list = $this->getAllPermissions();
|
||||
foreach ($permission_list as $key => $row) {
|
||||
$row->hash_id = Hasher::encode('permissions', $row->id);
|
||||
}
|
||||
return $permission_list;
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
use App\Http\Helpers\ImageHandel;
|
||||
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasRoles, Notifiable;
|
||||
|
||||
protected $guard_name = 'user';
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
];
|
||||
|
||||
protected $appends = ['hash_id'];
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('users', $this->id);
|
||||
}
|
||||
|
||||
public function getImgAttribute($value)
|
||||
{
|
||||
$file_info = [];
|
||||
$file_info = ImageHandel::getImgFullPath($value, 'person');
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
Reference in New Issue
Block a user