first commit
This commit is contained in:
15
backend/app/Models/Auth/Departments.php
Normal file
15
backend/app/Models/Auth/Departments.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Departments extends Model{
|
||||
}
|
||||
32
backend/app/Models/Auth/Permissions.php
Normal file
32
backend/app/Models/Auth/Permissions.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permissions extends Model{
|
||||
|
||||
protected $casts = [
|
||||
'hidden' => 'integer',
|
||||
'hiddenBreadcrumb' => 'integer',
|
||||
'affix' => 'integer',
|
||||
'fullpage' => 'integer',
|
||||
];
|
||||
protected $appends = ['meta'];
|
||||
|
||||
protected function meta(): Attribute{
|
||||
return Attribute::make(
|
||||
get: fn ($value, $data) => [
|
||||
'title' => $data['title'],
|
||||
'type' => $data['type'],
|
||||
'icon' => $data['icon'],
|
||||
'color' => $data['color'],
|
||||
'hidden' => $data['hidden'],
|
||||
'hiddenBreadcrumb' => $data['hiddenBreadcrumb'],
|
||||
'affix' => $data['affix'],
|
||||
'fullpage' => $data['fullpage'],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
15
backend/app/Models/Auth/RoleHasPermissions.php
Normal file
15
backend/app/Models/Auth/RoleHasPermissions.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RoleHasPermissions extends Model{
|
||||
}
|
||||
19
backend/app/Models/Auth/Roles.php
Normal file
19
backend/app/Models/Auth/Roles.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Roles extends Model{
|
||||
|
||||
public function permissions(){
|
||||
return $this->belongsToMany(Permissions::class, RoleHasPermissions::class, 'permission_id', 'role_id');
|
||||
}
|
||||
}
|
||||
15
backend/app/Models/Auth/UserHasRoles.php
Normal file
15
backend/app/Models/Auth/UserHasRoles.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserHasRoles extends Model{
|
||||
}
|
||||
57
backend/app/Models/Auth/Users.php
Normal file
57
backend/app/Models/Auth/Users.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class Users extends Authenticatable implements JWTSubject{
|
||||
use Notifiable;
|
||||
|
||||
protected $primaryKey = 'uid';
|
||||
|
||||
// Rest omitted for brevity
|
||||
|
||||
/**
|
||||
* 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(){
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 角色关联
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function roles(){
|
||||
return $this->belongsToMany(Roles::class, UserHasRoles::class, 'role_id', 'uid');
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 部门关联
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function department(){
|
||||
return $this->hasOne(Departments::class, 'id', 'department_id');
|
||||
}
|
||||
}
|
||||
20
backend/app/Models/Auth/UsersLog.php
Normal file
20
backend/app/Models/Auth/UsersLog.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UsersLog extends Model{
|
||||
|
||||
protected $table = 'users_log';
|
||||
|
||||
public function user(){
|
||||
return $this->hasOne(Users::class, 'uid', 'uid');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user