fix : 모델 경로 수정
This commit is contained in:
43
app/Models/Commons/Category.php
Normal file
43
app/Models/Commons/Category.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use SoftDeletes, BelongsToTenant;
|
||||
|
||||
protected $table = 'common_codes';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'code_group',
|
||||
'code',
|
||||
'name',
|
||||
'parent_id',
|
||||
'attributes',
|
||||
'description',
|
||||
'is_active',
|
||||
'sort_order'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'attributes' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// 관계: 상위 코드
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
// 관계: 하위 코드들
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
43
app/Models/Commons/File.php
Normal file
43
app/Models/Commons/File.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'files';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'file_path',
|
||||
'original_name',
|
||||
'file_name',
|
||||
'file_name_old',
|
||||
'file_size',
|
||||
'mime_type',
|
||||
'description',
|
||||
'fileable_id',
|
||||
'fileable_type',
|
||||
'uploaded_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* 연관된 모델 (Polymorphic)
|
||||
*/
|
||||
public function fileable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 업로더 (User 등)
|
||||
*/
|
||||
public function uploader()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uploaded_by');
|
||||
}
|
||||
}
|
||||
23
app/Models/Commons/Menu.php
Normal file
23
app/Models/Commons/Menu.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Menu extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tenant_id', 'parent_id', 'name', 'url', 'is_active', 'sort_order',
|
||||
'hidden', 'is_external', 'external_url', 'icon'
|
||||
];
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Menu::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Menu::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
29
app/Models/Commons/Role.php
Normal file
29
app/Models/Commons/Role.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use App\Models\Members\UserRole;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
22
app/Models/Commons/RoleMenuPermission.php
Normal file
22
app/Models/Commons/RoleMenuPermission.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Commons;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
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