fix : 부서관리 기능 수정
- Route, Controller, Service, Swagger, DB 수정 - 모델 위치 이동
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use App\Traits\ModelTrait;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperDepartment
|
||||
*/
|
||||
class Department extends Model
|
||||
{
|
||||
use SoftDeletes, BelongsToTenant, ModelTrait;
|
||||
|
||||
protected $table = 'departments';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id','code','name','description','is_active','sort_order',
|
||||
'created_by','updated_by','deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tenant_id' => 'integer',
|
||||
'is_active' => 'integer',
|
||||
'sort_order'=> 'integer',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'deleted_by','deleted_at'
|
||||
];
|
||||
|
||||
/** Relations */
|
||||
public function departmentUsers()
|
||||
{
|
||||
return $this->hasMany(DepartmentUser::class, 'department_id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
// User 네임스페이스가 다르면 여기만 맞춰줘.
|
||||
return $this->belongsToMany(User::class, 'department_user', 'department_id', 'user_id')
|
||||
->withPivot(['tenant_id','is_primary','joined_at','left_at','created_at','updated_at','deleted_at'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function departmentPermissions()
|
||||
{
|
||||
return $this->hasMany(DepartmentPermission::class, 'department_id');
|
||||
}
|
||||
|
||||
public function permissions()
|
||||
{
|
||||
return $this->belongsToMany(\Spatie\Permission\Models\Permission::class, 'department_permissions', 'department_id', 'permission_id')
|
||||
->withPivot(['tenant_id','menu_id','is_allowed','created_at','updated_at','deleted_at'])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use App\Traits\ModelTrait;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperDepartmentPermission
|
||||
*/
|
||||
class DepartmentPermission extends Model
|
||||
{
|
||||
use SoftDeletes, BelongsToTenant, ModelTrait;
|
||||
|
||||
protected $table = 'department_permissions';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id','department_id','permission_id','menu_id','is_allowed',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tenant_id' => 'integer',
|
||||
'department_id' => 'integer',
|
||||
'permission_id' => 'integer',
|
||||
'menu_id' => 'integer',
|
||||
'is_allowed' => 'integer',
|
||||
];
|
||||
|
||||
public function department()
|
||||
{
|
||||
return $this->belongsTo(Department::class, 'department_id');
|
||||
}
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo(\Spatie\Permission\Models\Permission::class, 'permission_id');
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use App\Traits\ModelTrait;
|
||||
use App\Models\Members\User;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperDepartmentUser
|
||||
*/
|
||||
class DepartmentUser extends Model
|
||||
{
|
||||
use SoftDeletes, BelongsToTenant, ModelTrait;
|
||||
|
||||
protected $table = 'department_user';
|
||||
protected $fillable = [
|
||||
'tenant_id','department_id','user_id','is_primary','joined_at','left_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tenant_id' => 'integer',
|
||||
'department_id' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
'is_primary' => 'integer',
|
||||
'joined_at' => 'datetime',
|
||||
'left_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function department()
|
||||
{
|
||||
return $this->belongsTo(Department::class, 'department_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
// User 네임스페이스가 다르면 여기만 맞춰줘.
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use App\Models\Members\UserRole;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperRole
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tenant_id', 'name', 'description'
|
||||
];
|
||||
|
||||
public function menuPermissions()
|
||||
{
|
||||
return $this->hasMany(RoleMenuPermission::class, 'role_id');
|
||||
}
|
||||
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function userRoles()
|
||||
{
|
||||
return $this->hasMany(UserRole::class);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperRoleMenuPermission
|
||||
*/
|
||||
class RoleMenuPermission extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'role_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve'
|
||||
];
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
}
|
||||
|
||||
public function menu()
|
||||
{
|
||||
return $this->belongsTo(Menu::class, 'menu_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user