style: Laravel Pint 코드 포맷팅 적용

- PSR-12 스타일 가이드 준수
- 302개 파일 스타일 이슈 자동 수정
- 코드 로직 변경 없음 (포맷팅만)
This commit is contained in:
2025-11-06 17:45:49 +09:00
parent 48e76432ee
commit cc206fdbed
294 changed files with 4476 additions and 2561 deletions

View File

@@ -11,12 +11,12 @@ class AuditLog extends Model
protected $table = 'audit_logs';
protected $fillable = [
'tenant_id','target_type','target_id','action','before','after','actor_id','ip','ua','created_at',
'tenant_id', 'target_type', 'target_id', 'action', 'before', 'after', 'actor_id', 'ip', 'ua', 'created_at',
];
protected $casts = [
'before' => 'array',
'after' => 'array',
'after' => 'array',
'created_at' => 'datetime',
];
}

View File

@@ -2,7 +2,6 @@
namespace App\Models\Boards;
use Illuminate\Database\Eloquent\Model;
/**
@@ -11,15 +10,19 @@
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'
'allow_files', 'max_file_count', 'max_file_size', 'extra_settings', 'is_active',
];
public function customFields() {
public function customFields()
{
return $this->hasMany(BoardSetting::class, 'board_id');
}
public function posts() {
public function posts()
{
return $this->hasMany(Post::class, 'board_id');
}
}

View File

@@ -2,9 +2,9 @@
namespace App\Models\Boards;
use App\Models\Members\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Members\User;
/**
* @mixin IdeHelperBoardComment
@@ -14,20 +14,28 @@ class BoardComment extends Model
use SoftDeletes;
protected $table = 'board_comments';
protected $fillable = [
'post_id', 'tenant_id', 'user_id', 'parent_id', 'content', 'ip_address', 'status'
'post_id', 'tenant_id', 'user_id', 'parent_id', 'content', 'ip_address', 'status',
];
public function post() {
public function post()
{
return $this->belongsTo(Post::class, 'post_id');
}
public function user() {
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function parent() {
public function parent()
{
return $this->belongsTo(BoardComment::class, 'parent_id');
}
public function children() {
public function children()
{
return $this->hasMany(BoardComment::class, 'parent_id')->where('status', 'active');
}
}

View File

@@ -10,11 +10,13 @@
class BoardSetting extends Model
{
protected $table = 'board_settings';
protected $fillable = [
'board_id', 'name', 'field_key', 'field_type', 'field_meta', 'is_required', 'sort_order'
'board_id', 'name', 'field_key', 'field_type', 'field_meta', 'is_required', 'sort_order',
];
public function board() {
public function board()
{
return $this->belongsTo(Board::class, 'board_id');
}
}

View File

@@ -2,9 +2,9 @@
namespace App\Models\Boards;
use App\Models\Commons\File;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Commons\File;
/**
* @mixin IdeHelperPost
@@ -14,18 +14,24 @@ 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'
'ip_address', 'is_notice', 'is_secret', 'views', 'status',
];
public function files() {
public function files()
{
return $this->morphMany(File::class, 'fileable');
}
public function comments() {
public function comments()
{
return $this->hasMany(BoardComment::class, 'post_id')->whereNull('parent_id')->where('status', 'active');
}
public function board() {
public function board()
{
return $this->belongsTo(Board::class, 'board_id');
}
}

View File

@@ -10,12 +10,16 @@
class PostCustomFieldValue extends Model
{
protected $table = 'post_custom_field_values';
protected $fillable = ['post_id', 'field_id', 'value'];
public function post() {
public function post()
{
return $this->belongsTo(Post::class, 'post_id');
}
public function field() {
public function field()
{
return $this->belongsTo(BoardSetting::class, 'field_id');
}
}

View File

@@ -2,8 +2,8 @@
namespace App\Models\Calculation;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class CalculationConfig extends Model
{
@@ -21,14 +21,14 @@ class CalculationConfig extends Model
'description',
'is_active',
'created_by',
'updated_by'
'updated_by',
];
protected $casts = [
'parameters' => 'array',
'conditions' => 'array',
'validation_rules' => 'array',
'is_active' => 'boolean'
'is_active' => 'boolean',
];
/**
@@ -99,4 +99,4 @@ public static function getLatestFormula(int $tenantId, string $companyName, stri
->latestVersion()
->first();
}
}
}

View File

@@ -9,38 +9,61 @@
class Category extends Model
{
use SoftDeletes, BelongsToTenant, ModelTrait;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'tenant_id','parent_id','code_group','code','name',
'tenant_id', 'parent_id', 'code_group', 'code', 'name',
'profile_code', // capability_profile 연결
'is_active','sort_order','description',
'created_by','updated_by','deleted_by'
'is_active', 'sort_order', 'description',
'created_by', 'updated_by', 'deleted_by',
];
protected $casts = [
'is_active' => 'boolean',
'is_active' => 'boolean',
'sort_order' => 'integer',
];
protected $hidden = [
'deleted_by','deleted_at'
'deleted_by', 'deleted_at',
];
// 계층
public function parent() { return $this->belongsTo(self::class, 'parent_id'); }
public function children() { return $this->hasMany(self::class, 'parent_id'); }
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
public function children()
{
return $this->hasMany(self::class, 'parent_id');
}
// 카테고리의 제품들
public function products() { return $this->hasMany(\App\Models\Products\Product::class, 'category_id'); }
public function products()
{
return $this->hasMany(\App\Models\Products\Product::class, 'category_id');
}
// 카테고리 필드
public function categoryFields() { return $this->hasMany(CategoryField::class, 'category_id'); }
public function categoryFields()
{
return $this->hasMany(CategoryField::class, 'category_id');
}
// 태그(폴리모픽) — 이미 taggables 존재
public function tags() { return $this->morphToMany(\App\Models\Commons\Tag::class, 'taggable'); }
public function tags()
{
return $this->morphToMany(\App\Models\Commons\Tag::class, 'taggable');
}
// 스코프
public function scopeGroup($q, string $group) { return $q->where('code_group', $group); }
public function scopeCode($q, string $code) { return $q->where('code', $code); }
public function scopeGroup($q, string $group)
{
return $q->where('code_group', $group);
}
public function scopeCode($q, string $code)
{
return $q->where('code', $code);
}
}

View File

@@ -9,21 +9,21 @@
class CategoryField extends Model
{
use SoftDeletes, BelongsToTenant, ModelTrait;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $table = 'category_fields';
protected $fillable = [
'tenant_id','category_id',
'field_key','field_name','field_type',
'is_required','sort_order','default_value','options','description',
'created_by','updated_by','deleted_by',
'tenant_id', 'category_id',
'field_key', 'field_name', 'field_type',
'is_required', 'sort_order', 'default_value', 'options', 'description',
'created_by', 'updated_by', 'deleted_by',
];
protected $casts = [
'is_required' => 'boolean',
'sort_order' => 'integer',
'options' => 'array',
'sort_order' => 'integer',
'options' => 'array',
];
public function category()
@@ -32,5 +32,8 @@ public function category()
}
// 편의 스코프
public function scopeRequired($q) { return $q->where('is_required', 1); }
public function scopeRequired($q)
{
return $q->where('is_required', 1);
}
}

View File

@@ -11,17 +11,18 @@ class CategoryLog extends Model
use BelongsToTenant, ModelTrait;
protected $table = 'category_logs';
public $timestamps = false; // changed_at 컬럼 단일 사용
protected $fillable = [
'category_id','tenant_id','action','changed_by','changed_at',
'before_json','after_json','remarks',
'category_id', 'tenant_id', 'action', 'changed_by', 'changed_at',
'before_json', 'after_json', 'remarks',
];
protected $casts = [
'changed_at' => 'datetime',
'changed_at' => 'datetime',
'before_json' => 'array',
'after_json' => 'array',
'after_json' => 'array',
];
public function category()

View File

@@ -13,14 +13,14 @@ class CategoryTemplate extends Model
protected $table = 'category_templates';
protected $fillable = [
'tenant_id','category_id','version_no','template_json','applied_at',
'created_by','updated_by','deleted_by','remarks',
'tenant_id', 'category_id', 'version_no', 'template_json', 'applied_at',
'created_by', 'updated_by', 'deleted_by', 'remarks',
];
protected $casts = [
'version_no' => 'integer',
'version_no' => 'integer',
'template_json' => 'array',
'applied_at' => 'datetime',
'applied_at' => 'datetime',
];
public function category()

View File

@@ -9,7 +9,7 @@
class Classification extends Model
{
use SoftDeletes, ModelTrait, BelongsToTenant;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'tenant_id',

View File

@@ -2,9 +2,9 @@
namespace App\Models\Commons;
use App\Models\Members\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Members\User;
/**
* @mixin IdeHelperFile

View File

@@ -2,18 +2,18 @@
namespace App\Models\Commons;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Scopes\TenantScope;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use App\Models\Scopes\TenantScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @mixin IdeHelperMenu
*/
class Menu extends Model
{
use SoftDeletes, BelongsToTenant, ModelTrait;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'tenant_id', 'parent_id', 'name', 'url', 'is_active', 'sort_order',
@@ -25,7 +25,7 @@ class Menu extends Model
'created_by',
'updated_by',
'deleted_by',
'deleted_at'
'deleted_at',
];
public function parent()

View File

@@ -23,7 +23,6 @@ public function tenant(): BelongsTo
return $this->belongsTo(Tenant::class);
}
/**
* 제품(Product)와 연결 (N:M, 폴리모픽)
*/
@@ -47,5 +46,4 @@ public function materials(): MorphToMany
{
return $this->morphedByMany(Material::class, 'taggable');
}
}

View File

@@ -12,8 +12,8 @@ class BomTemplate extends Model
protected $table = 'bom_templates';
protected $fillable = [
'tenant_id','model_version_id','name','is_primary','notes',
'calculation_schema','company_type','formula_version',
'tenant_id', 'model_version_id', 'name', 'is_primary', 'notes',
'calculation_schema', 'company_type', 'formula_version',
];
protected $casts = [
@@ -21,11 +21,13 @@ class BomTemplate extends Model
'calculation_schema' => 'array',
];
public function modelVersion() {
public function modelVersion()
{
return $this->belongsTo(ModelVersion::class, 'model_version_id');
}
public function items() {
public function items()
{
return $this->hasMany(BomTemplateItem::class, 'bom_template_id');
}
}

View File

@@ -9,8 +9,8 @@ class BomTemplateItem extends Model
protected $table = 'bom_template_items';
protected $fillable = [
'tenant_id','bom_template_id','ref_type','ref_id','qty','waste_rate','uom_id','notes','sort_order',
'is_calculated','calculation_formula','depends_on','calculation_config',
'tenant_id', 'bom_template_id', 'ref_type', 'ref_id', 'qty', 'waste_rate', 'uom_id', 'notes', 'sort_order',
'is_calculated', 'calculation_formula', 'depends_on', 'calculation_config',
];
protected $casts = [
@@ -21,7 +21,8 @@ class BomTemplateItem extends Model
'calculation_config' => 'array',
];
public function template() {
public function template()
{
return $this->belongsTo(BomTemplate::class, 'bom_template_id');
}
}

View File

@@ -12,7 +12,7 @@ class DesignModel extends Model
protected $table = 'models';
protected $fillable = [
'tenant_id','code','name','category_id','lifecycle','description','is_active',
'tenant_id', 'code', 'name', 'category_id', 'lifecycle', 'description', 'is_active',
];
protected $casts = [
@@ -20,7 +20,8 @@ class DesignModel extends Model
];
// 관계: 모델은 여러 버전을 가짐
public function versions() {
public function versions()
{
return $this->hasMany(ModelVersion::class, 'model_id');
}
}

View File

@@ -12,7 +12,7 @@ class ModelVersion extends Model
protected $table = 'model_versions';
protected $fillable = [
'tenant_id','model_id','version_no','status','effective_from','effective_to','notes','is_active',
'tenant_id', 'model_id', 'version_no', 'status', 'effective_from', 'effective_to', 'notes', 'is_active',
];
protected $casts = [
@@ -21,15 +21,18 @@ class ModelVersion extends Model
'effective_to' => 'datetime',
];
public function model() {
public function model()
{
return $this->belongsTo(DesignModel::class, 'model_id');
}
public function bomTemplates() {
public function bomTemplates()
{
return $this->hasMany(BomTemplate::class, 'model_version_id');
}
public function scopeReleased($q) {
public function scopeReleased($q)
{
return $q->where('status', 'RELEASED');
}
}

View File

@@ -12,7 +12,7 @@
class Estimate extends Model
{
use HasFactory, SoftDeletes, BelongsToTenant;
use BelongsToTenant, HasFactory, SoftDeletes;
protected $fillable = [
'tenant_id',
@@ -75,7 +75,7 @@ public static function generateEstimateNo(int $tenantId): string
$sequence = $lastEstimate ? (int) substr($lastEstimate->estimate_no, -3) + 1 : 1;
return $prefix . $date . str_pad($sequence, 3, '0', STR_PAD_LEFT);
return $prefix.$date.str_pad($sequence, 3, '0', STR_PAD_LEFT);
}
/**
@@ -102,6 +102,6 @@ public function scopeApproved($query)
public function scopeExpired($query)
{
return $query->whereNotNull('valid_until')
->where('valid_until', '<', now());
->where('valid_until', '<', now());
}
}
}

View File

@@ -10,7 +10,7 @@
class EstimateItem extends Model
{
use HasFactory, SoftDeletes, BelongsToTenant;
use BelongsToTenant, HasFactory, SoftDeletes;
protected $fillable = [
'tenant_id',
@@ -77,4 +77,4 @@ protected static function boot()
$item->total_price = $item->calculateTotalPrice();
});
}
}
}

View File

@@ -42,12 +42,12 @@ public function flows(): HasMany
*/
public function estimates()
{
//return $this->hasMany(MainRequestEstimate::class, 'main_request_id');
// return $this->hasMany(MainRequestEstimate::class, 'main_request_id');
}
public function orders()
{
//return $this->hasMany(MainRequestOrder::class, 'main_request_id');
// return $this->hasMany(MainRequestOrder::class, 'main_request_id');
}
// ... 필요에 따라 파생 업무별 hasMany 관계 추가

View File

@@ -2,7 +2,6 @@
namespace App\Models;
use App\Models\MainRequest;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;

View File

@@ -5,9 +5,8 @@
use App\Models\Commons\File;
use App\Models\Commons\Tag;
use App\Models\Qualitys\Lot;
use App\Traits\ModelTrait;
use App\Traits\BelongsToTenant;
use Filament\Forms\Components\Hidden;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -16,7 +15,7 @@
*/
class Material extends Model
{
use SoftDeletes, ModelTrait, BelongsToTenant;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'tenant_id',
@@ -37,7 +36,7 @@ class Material extends Model
protected $casts = [
'attributes' => 'array',
'options' => 'array',
'options' => 'array',
];
protected $hidden = [

View File

@@ -15,7 +15,7 @@ class MaterialReceipt extends Model
protected $fillable = [
'material_id', 'receipt_date', 'lot_number', 'received_qty', 'unit',
'supplier_name', 'manufacturer_name', 'purchase_price_excl_vat',
'weight_kg', 'status_code', 'is_inspection', 'inspection_date', 'remarks'
'weight_kg', 'status_code', 'is_inspection', 'inspection_date', 'remarks',
];
// 자재 마스터

View File

@@ -17,7 +17,7 @@
*/
class User extends Authenticatable
{
use HasApiTokens, Notifiable, SoftDeletes, ModelTrait, HasRoles;
use HasApiTokens, HasRoles, ModelTrait, Notifiable, SoftDeletes;
protected $guard_name = 'api'; // ★ 중요: 권한/역할 가드 통일
@@ -33,10 +33,10 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
'last_login_at' => 'datetime',
'options' => 'array',
'deleted_at' => 'datetime',
'password' => 'hashed', // ← 이걸 쓰면 자동 해싱
'last_login_at' => 'datetime',
'options' => 'array',
'deleted_at' => 'datetime',
'password' => 'hashed', // ← 이걸 쓰면 자동 해싱
];
protected $hidden = [

View File

@@ -11,7 +11,7 @@
class UserMenuPermission extends Model
{
protected $fillable = [
'user_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve'
'user_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve',
];
public function user()

View File

@@ -13,10 +13,10 @@
*/
class UserRole extends Model
{
use SoftDeletes, BelongsToTenant;
use BelongsToTenant, SoftDeletes;
protected $fillable = [
'user_id', 'tenant_id', 'role_id', 'assigned_at'
'user_id', 'tenant_id', 'role_id', 'assigned_at',
];
public function user()

View File

@@ -13,10 +13,10 @@
*/
class UserTenant extends Model
{
use SoftDeletes, ModelTrait, BelongsToTenant;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'user_id', 'tenant_id', 'is_active', 'is_default', 'joined_at', 'left_at'
'user_id', 'tenant_id', 'is_active', 'is_default', 'joined_at', 'left_at',
];
protected $guarded = [
@@ -27,11 +27,11 @@ class UserTenant extends Model
];
protected $casts = [
'joined_at' => 'datetime',
'left_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'joined_at' => 'datetime',
'left_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
protected $hidden = [

View File

@@ -18,7 +18,7 @@ class Order extends Model
protected $fillable = [
'tenant_id', 'order_no', 'order_type_code', 'status_code', 'category_code', 'product_id',
'received_at', 'writer_id', 'client_id', 'client_contact', 'site_name', 'quantity', 'delivery_date',
'delivery_method_code', 'memo'
'delivery_method_code', 'memo',
];
// 상세(라인)

View File

@@ -13,7 +13,7 @@ class OrderHistory extends Model
protected $table = 'order_histories';
protected $fillable = [
'tenant_id', 'order_id', 'history_type', 'content', 'created_by'
'tenant_id', 'order_id', 'history_type', 'content', 'created_by',
];
public function order()

View File

@@ -17,7 +17,7 @@ class OrderItem extends Model
protected $fillable = [
'tenant_id', 'order_id', 'serial_no', 'product_id', 'quantity',
'status_code', 'design_code', 'remarks', 'attributes'
'status_code', 'design_code', 'remarks', 'attributes',
];
// 투입 구성(자재/BOM 등)

View File

@@ -17,7 +17,7 @@ class OrderItemComponent extends Model
protected $fillable = [
'tenant_id', 'order_item_id', 'component_type', 'component_id', 'quantity',
'unit', 'price', 'remarks', 'created_by', 'updated_by'
'unit', 'price', 'remarks', 'created_by', 'updated_by',
];
public function orderItem()

View File

@@ -13,7 +13,7 @@ class OrderVersion extends Model
protected $table = 'order_versions';
protected $fillable = [
'tenant_id', 'order_id', 'version_no', 'version_type', 'status_code', 'changed_fields', 'created_by', 'change_note'
'tenant_id', 'order_id', 'version_no', 'version_type', 'status_code', 'changed_fields', 'created_by', 'change_note',
];
public function order()

View File

@@ -17,4 +17,4 @@ public function tenant()
{
return $this->belongsTo(Tenant::class);
}
}
}

View File

@@ -11,15 +11,16 @@ class PermissionOverride extends Model
use SoftDeletes;
protected $table = 'permission_overrides';
protected $guarded = ['id'];
protected $casts = [
'tenant_id' => 'int',
'model_id' => 'int',
'permission_id' => 'int',
'effect' => 'int', // 1=ALLOW, -1=DENY
'tenant_id' => 'int',
'model_id' => 'int',
'permission_id' => 'int',
'effect' => 'int', // 1=ALLOW, -1=DENY
'effective_from' => 'datetime',
'effective_to' => 'datetime',
'effective_to' => 'datetime',
];
/**

View File

@@ -13,7 +13,7 @@
class Role extends Model
{
protected $fillable = [
'tenant_id', 'name', 'description'
'tenant_id', 'name', 'description',
];
public function menuPermissions()

View File

@@ -12,7 +12,7 @@
class RoleMenuPermission extends Model
{
protected $fillable = [
'role_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve'
'role_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve',
];
public function role()

View File

@@ -2,16 +2,17 @@
namespace App\Models\Products;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @mixin IdeHelperCommonCode
*/
class CommonCode extends Model
{
use SoftDeletes, BelongsToTenant, ModelTrait;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $table = 'common_codes';
@@ -24,7 +25,7 @@ class CommonCode extends Model
'attributes',
'description',
'is_active',
'sort_order'
'sort_order',
];
protected $casts = [

View File

@@ -12,12 +12,16 @@
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() {
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() {
public function partType()
{
return $this->belongsTo(CommonCode::class, 'part_type_id');
}

View File

@@ -12,22 +12,22 @@
class Product extends Model
{
use SoftDeletes, BelongsToTenant, ModelTrait;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'tenant_id','code','name','unit','category_id',
'tenant_id', 'code', 'name', 'unit', 'category_id',
'product_type', // 라벨/분류용
'attributes','description',
'is_sellable','is_purchasable','is_producible','is_active',
'created_by','updated_by'
'attributes', 'description',
'is_sellable', 'is_purchasable', 'is_producible', 'is_active',
'created_by', 'updated_by',
];
protected $casts = [
'attributes' => 'array',
'is_sellable' => 'boolean',
'attributes' => 'array',
'is_sellable' => 'boolean',
'is_purchasable' => 'boolean',
'is_producible' => 'boolean',
'is_active' => 'boolean',
'is_producible' => 'boolean',
'is_active' => 'boolean',
];
protected $hidden = [
@@ -35,7 +35,10 @@ class Product extends Model
];
// 분류
public function category() { return $this->belongsTo(Category::class, 'category_id'); }
public function category()
{
return $this->belongsTo(Category::class, 'category_id');
}
// BOM (자기참조) — 라인 모델 경유
public function componentLines()
@@ -54,7 +57,7 @@ public function children()
{
return $this->belongsToMany(
self::class, 'product_components', 'parent_product_id', 'child_product_id'
)->withPivot(['quantity','sort_order','is_default'])
)->withPivot(['quantity', 'sort_order', 'is_default'])
->withTimestamps();
}
@@ -62,17 +65,39 @@ public function parents()
{
return $this->belongsToMany(
self::class, 'product_components', 'child_product_id', 'parent_product_id'
)->withPivot(['quantity','sort_order','is_default'])
)->withPivot(['quantity', 'sort_order', 'is_default'])
->withTimestamps();
}
// 파일 / 태그 (폴리모픽)
public function files() { return $this->morphMany(File::class, 'fileable'); }
public function tags() { return $this->morphToMany(Tag::class, 'taggable'); }
public function files()
{
return $this->morphMany(File::class, 'fileable');
}
public function tags()
{
return $this->morphToMany(Tag::class, 'taggable');
}
// 스코프
public function scopeType($q, string $type) { return $q->where('product_type', $type); }
public function scopeSellable($q) { return $q->where('is_sellable', 1); }
public function scopePurchasable($q) { return $q->where('is_purchasable', 1); }
public function scopeProducible($q) { return $q->where('is_producible', 1); }
public function scopeType($q, string $type)
{
return $q->where('product_type', $type);
}
public function scopeSellable($q)
{
return $q->where('is_sellable', 1);
}
public function scopePurchasable($q)
{
return $q->where('is_purchasable', 1);
}
public function scopeProducible($q)
{
return $q->where('is_producible', 1);
}
}

View File

@@ -3,14 +3,14 @@
namespace App\Models\Products;
use App\Models\Materials\Material;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Traits\ModelTrait;
use App\Traits\BelongsToTenant;
class ProductComponent extends Model
{
use SoftDeletes, ModelTrait, BelongsToTenant;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $table = 'product_components';
@@ -28,7 +28,7 @@ class ProductComponent extends Model
];
protected $casts = [
'quantity' => 'decimal:6',
'quantity' => 'decimal:6',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
@@ -57,6 +57,7 @@ public function referencedItem()
} elseif ($this->ref_type === 'MATERIAL') {
return $this->belongsTo(Material::class, 'ref_id');
}
return null;
}

View File

@@ -1,6 +1,5 @@
<?php
namespace App\Models\Qualitys;
use Illuminate\Database\Eloquent\Model;

View File

@@ -16,7 +16,9 @@ public function apply(Builder $builder, Model $model)
{
// artisan migrate 등은 제외
if (app()->runningInConsole()) return;
if (app()->runningInConsole()) {
return;
}
// request 헬퍼 사용 → request 인스턴스를 명시적으로 주입받아 사용해야 함
$request = app(Request::class);

View File

@@ -13,10 +13,12 @@ class SiteAdmin extends Model
use UppercaseAttributes; // 테이블 컬럼명 대문자 처리
protected $table = 'SITE_ADMIN';
protected $primaryKey = 'UNO';
public $timestamps = false;
protected $fillable = [
'UNO', 'LEVEL'. 'COMMENT'
'UNO', 'LEVEL'.'COMMENT',
];
}

View File

@@ -3,29 +3,31 @@
namespace App\Models\Tenants;
use App\Models\Members\User;
use App\Models\Permissions\PermissionOverride;
use App\Models\Tenants\Pivots\DepartmentUser;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Spatie\Permission\Traits\HasRoles;
use App\Traits\ModelTrait;
use App\Models\Tenants\Pivots\DepartmentUser;
use App\Models\Permissions\PermissionOverride;
class Department extends Model
{
use HasRoles, ModelTrait; // 부서도 권한/역할을 가짐
protected $table = 'departments';
protected $guarded = ['id'];
protected $casts = [
'tenant_id' => 'int',
'parent_id' => 'int',
'is_active' => 'bool',
'sort_order'=> 'int',
'sort_order' => 'int',
];
protected $hidden = [
'deleted_by','deleted_at'
'deleted_by', 'deleted_at',
];
// 스파티 가드명(프로젝트 설정에 맞게 조정)
@@ -48,7 +50,7 @@ public function users()
return $this->belongsToMany(User::class, 'department_user')
->using(DepartmentUser::class)
->withTimestamps()
->withPivot(['tenant_id','is_primary','joined_at','left_at']);
->withPivot(['tenant_id', 'is_primary', 'joined_at', 'left_at']);
}
/** 부서의 권한 오버라이드(DENY/임시허용) */

View File

@@ -13,14 +13,15 @@ class Payment extends Model
use SoftDeletes;
protected $fillable = [
'subscription_id', 'amount', 'payment_method', 'transaction_id', 'paid_at', 'status', 'memo'
'subscription_id', 'amount', 'payment_method', 'transaction_id', 'paid_at', 'status', 'memo',
];
protected $dates = [
'paid_at',
];
public function subscription() {
public function subscription()
{
return $this->belongsTo(Subscription::class);
}
}

View File

@@ -15,20 +15,21 @@
*/
class DepartmentUser extends Model
{
use SoftDeletes, BelongsToTenant, ModelTrait;
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $table = 'department_user';
protected $fillable = [
'tenant_id','department_id','user_id','is_primary','joined_at','left_at',
'tenant_id', 'department_id', 'user_id', 'is_primary', 'joined_at', 'left_at',
];
protected $casts = [
'tenant_id' => 'integer',
'tenant_id' => 'integer',
'department_id' => 'integer',
'user_id' => 'integer',
'is_primary' => 'integer',
'joined_at' => 'datetime',
'left_at' => 'datetime',
'user_id' => 'integer',
'is_primary' => 'integer',
'joined_at' => 'datetime',
'left_at' => 'datetime',
];
public function department()

View File

@@ -22,7 +22,8 @@ class Plan extends Model
'price' => 'float',
];
public function subscriptions() {
public function subscriptions()
{
return $this->hasMany(Subscription::class);
}
}

View File

@@ -20,15 +20,18 @@ class Subscription extends Model
'started_at', 'ended_at',
];
public function tenant() {
public function tenant()
{
return $this->belongsTo(Tenant::class);
}
public function plan() {
public function plan()
{
return $this->belongsTo(Plan::class);
}
public function payments() {
public function payments()
{
return $this->hasMany(Payment::class);
}
}

View File

@@ -16,7 +16,7 @@
*/
class Tenant extends Model
{
use SoftDeletes, ModelTrait;
use ModelTrait, SoftDeletes;
protected $fillable = [
'company_name',
@@ -46,14 +46,14 @@ class Tenant extends Model
];
protected $casts = [
'trial_ends_at' => 'datetime',
'expires_at' => 'datetime',
'last_paid_at' => 'datetime',
'max_users' => 'integer',
'options' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'trial_ends_at' => 'datetime',
'expires_at' => 'datetime',
'last_paid_at' => 'datetime',
'max_users' => 'integer',
'options' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
protected $hidden = [