style: Laravel Pint 코드 포맷팅 적용
- PSR-12 스타일 가이드 준수 - 302개 파일 스타일 이슈 자동 수정 - 코드 로직 변경 없음 (포맷팅만)
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user