feat : 테이블 및 DB 마이그레이션 파일 추가
products - common_codes - parts - products - files - price_histories - boms - bom_items boards - boards - board_settings - posts - board_comments - board_files - post_custom_field_values permissions - menus - roles - user_menu_permissions - role_menu_permissions tenants - tenants - plans - subscriptions - payments
This commit is contained in:
21
app/Models/Boards/Board.php
Normal file
21
app/Models/Boards/Board.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Boards;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Board extends Model
|
||||
{
|
||||
protected $table = 'boards';
|
||||
protected $fillable = [
|
||||
'tenant_id', 'board_code', 'name', 'description', 'editor_type',
|
||||
'allow_files', 'max_file_count', 'max_file_size', 'extra_settings', 'is_active'
|
||||
];
|
||||
|
||||
public function customFields() {
|
||||
return $this->hasMany(BoardSetting::class, 'board_id');
|
||||
}
|
||||
public function posts() {
|
||||
return $this->hasMany(Post::class, 'board_id');
|
||||
}
|
||||
}
|
||||
29
app/Models/Boards/BoardComment.php
Normal file
29
app/Models/Boards/BoardComment.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Boards;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BoardComment extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'board_comments';
|
||||
protected $fillable = [
|
||||
'post_id', 'tenant_id', 'user_id', 'parent_id', 'content', 'ip_address', 'status'
|
||||
];
|
||||
|
||||
public function post() {
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
public function user() {
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
public function parent() {
|
||||
return $this->belongsTo(BoardComment::class, 'parent_id');
|
||||
}
|
||||
public function children() {
|
||||
return $this->hasMany(BoardComment::class, 'parent_id')->where('status', 'active');
|
||||
}
|
||||
}
|
||||
15
app/Models/Boards/BoardFile.php
Normal file
15
app/Models/Boards/BoardFile.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Boards;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BoardFile extends Model
|
||||
{
|
||||
protected $table = 'board_files';
|
||||
protected $fillable = ['post_id', 'file_path', 'file_name', 'file_size', 'file_type'];
|
||||
|
||||
public function post() {
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
}
|
||||
15
app/Models/Boards/BoardSetting.php
Normal file
15
app/Models/Boards/BoardSetting.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BoardSetting extends Model
|
||||
{
|
||||
protected $table = 'board_settings';
|
||||
protected $fillable = [
|
||||
'board_id', 'name', 'field_key', 'field_type', 'field_meta', 'is_required', 'sort_order'
|
||||
];
|
||||
|
||||
public function board() {
|
||||
return $this->belongsTo(Board::class, 'board_id');
|
||||
}
|
||||
}
|
||||
30
app/Models/Boards/Post.php
Normal file
30
app/Models/Boards/Post.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Boards;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'posts';
|
||||
protected $fillable = [
|
||||
'tenant_id', 'board_id', 'user_id', 'title', 'content', 'editor_type',
|
||||
'ip_address', 'is_notice', 'is_secret', 'views', 'status'
|
||||
];
|
||||
|
||||
public function customFieldValues() {
|
||||
return $this->hasMany(PostCustomFieldValue::class, 'post_id');
|
||||
}
|
||||
public function files() {
|
||||
return $this->hasMany(BoardFile::class, 'post_id');
|
||||
}
|
||||
public function comments() {
|
||||
return $this->hasMany(BoardComment::class, 'post_id')->whereNull('parent_id')->where('status', 'active');
|
||||
}
|
||||
public function board() {
|
||||
return $this->belongsTo(Board::class, 'board_id');
|
||||
}
|
||||
}
|
||||
18
app/Models/Boards/PostCustomFieldValue.php
Normal file
18
app/Models/Boards/PostCustomFieldValue.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Boards;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PostCustomFieldValue extends Model
|
||||
{
|
||||
protected $table = 'post_custom_field_values';
|
||||
protected $fillable = ['post_id', 'field_id', 'value'];
|
||||
|
||||
public function post() {
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
public function field() {
|
||||
return $this->belongsTo(BoardSetting::class, 'field_id');
|
||||
}
|
||||
}
|
||||
23
app/Models/Menu.php
Normal file
23
app/Models/Menu.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
23
app/Models/Payment.php
Normal file
23
app/Models/Payment.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'subscription_id', 'amount', 'payment_method', 'transaction_id', 'paid_at', 'status', 'memo'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'paid_at',
|
||||
];
|
||||
|
||||
public function subscription() {
|
||||
return $this->belongsTo(Subscription::class);
|
||||
}
|
||||
}
|
||||
25
app/Models/Plan.php
Normal file
25
app/Models/Plan.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Plan extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'code', 'description', 'price', 'billing_cycle', 'features', 'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'features' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'price' => 'float',
|
||||
];
|
||||
|
||||
public function subscriptions() {
|
||||
return $this->hasMany(Subscription::class);
|
||||
}
|
||||
}
|
||||
25
app/Models/Products/Bom.php
Normal file
25
app/Models/Products/Bom.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Bom extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','product_id','code','name','category_id','attributes','description','is_default','is_active','image_file_id'];
|
||||
|
||||
public function product() {
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
public function category() {
|
||||
return $this->belongsTo(CommonCode::class, 'category_id');
|
||||
}
|
||||
public function items() {
|
||||
return $this->hasMany(BomItem::class);
|
||||
}
|
||||
public function image() {
|
||||
return $this->belongsTo(File::class, 'image_file_id');
|
||||
}
|
||||
}
|
||||
22
app/Models/Products/BomItem.php
Normal file
22
app/Models/Products/BomItem.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BomItem extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','bom_id','parent_id','item_type','ref_id','quantity','attributes','sort_order'];
|
||||
|
||||
public function bom() {
|
||||
return $this->belongsTo(Bom::class);
|
||||
}
|
||||
public function parent() {
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
public function children() {
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
19
app/Models/Products/CommonCode.php
Normal file
19
app/Models/Products/CommonCode.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CommonCode extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','code_group','code','name','parent_id','description','is_active','sort_order'];
|
||||
|
||||
public function parent() {
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
public function children() {
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
12
app/Models/Products/File.php
Normal file
12
app/Models/Products/File.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','file_path','file_name','file_size','mime_type','description'];
|
||||
}
|
||||
21
app/Models/Products/Part.php
Normal file
21
app/Models/Products/Part.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Part extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','code','name','category_id','part_type_id','unit','attributes','description','is_active'];
|
||||
|
||||
public function category() {
|
||||
return $this->belongsTo(CommonCode::class, 'category_id');
|
||||
}
|
||||
public function partType() {
|
||||
return $this->belongsTo(CommonCode::class, 'part_type_id');
|
||||
}
|
||||
}
|
||||
12
app/Models/Products/PriceHistory.php
Normal file
12
app/Models/Products/PriceHistory.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PriceHistory extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','item_type_code','item_id','price_type_code','price','started_at','ended_at'];
|
||||
}
|
||||
19
app/Models/Products/Product.php
Normal file
19
app/Models/Products/Product.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Products;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['tenant_id','code','name','category_id','attributes','description','is_active'];
|
||||
|
||||
public function category() {
|
||||
return $this->belongsTo(CommonCode::class, 'category_id');
|
||||
}
|
||||
public function boms() {
|
||||
return $this->hasMany(Bom::class);
|
||||
}
|
||||
}
|
||||
17
app/Models/Role.php
Normal file
17
app/Models/Role.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
22
app/Models/RoleMenuPermission.php
Normal file
22
app/Models/RoleMenuPermission.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
31
app/Models/Subscription.php
Normal file
31
app/Models/Subscription.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Subscription extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id', 'plan_id', 'started_at', 'ended_at', 'status',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'started_at', 'ended_at',
|
||||
];
|
||||
|
||||
public function tenant() {
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function plan() {
|
||||
return $this->belongsTo(Plan::class);
|
||||
}
|
||||
|
||||
public function payments() {
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
}
|
||||
45
app/Models/Tenant.php
Normal file
45
app/Models/Tenant.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Tenant extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'email',
|
||||
'phone',
|
||||
'address',
|
||||
'tenant_st_code',
|
||||
'plan_id',
|
||||
'subscription_id',
|
||||
'max_users',
|
||||
'trial_ends_at',
|
||||
'expires_at',
|
||||
'last_paid_at',
|
||||
'billing_tp_code',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'trial_ends_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
'last_paid_at' => 'datetime',
|
||||
'max_users' => 'integer',
|
||||
];
|
||||
|
||||
// 관계 정의 (예시)
|
||||
public function plan()
|
||||
{
|
||||
return $this->belongsTo(Plan::class, 'plan_id');
|
||||
}
|
||||
|
||||
public function subscription()
|
||||
{
|
||||
return $this->belongsTo(Subscription::class, 'subscription_id');
|
||||
}
|
||||
}
|
||||
22
app/Models/UserMenuPermission.php
Normal file
22
app/Models/UserMenuPermission.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserMenuPermission extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve'
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function menu()
|
||||
{
|
||||
return $this->belongsTo(Menu::class, 'menu_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user