feat(시공사): 2.1 현장관리 - Backend API 확장
- 마이그레이션: site_code, client_id, status 컬럼 추가 - Site 모델: 상태 상수, Client 관계 추가 - SiteService: stats(), bulkDestroy(), 필터 확장 - SiteController: stats, bulkDestroy 엔드포인트 추가 - 라우트: /stats, /bulk 추가 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use App\Models\Orders\Client;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use App\Traits\ModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -14,14 +15,18 @@
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $tenant_id
|
||||
* @property string|null $site_code 현장코드
|
||||
* @property int|null $client_id 거래처 ID
|
||||
* @property string $name
|
||||
* @property string|null $address
|
||||
* @property float|null $latitude
|
||||
* @property float|null $longitude
|
||||
* @property bool $is_active
|
||||
* @property string $status 상태: unregistered|suspended|active|pending
|
||||
* @property int|null $created_by
|
||||
* @property int|null $updated_by
|
||||
* @property int|null $deleted_by
|
||||
* @property-read Client|null $client
|
||||
*/
|
||||
class Site extends Model
|
||||
{
|
||||
@@ -29,13 +34,32 @@ class Site extends Model
|
||||
|
||||
protected $table = 'sites';
|
||||
|
||||
// 상태 상수
|
||||
public const STATUS_UNREGISTERED = 'unregistered';
|
||||
|
||||
public const STATUS_SUSPENDED = 'suspended';
|
||||
|
||||
public const STATUS_ACTIVE = 'active';
|
||||
|
||||
public const STATUS_PENDING = 'pending';
|
||||
|
||||
public const STATUSES = [
|
||||
self::STATUS_UNREGISTERED,
|
||||
self::STATUS_SUSPENDED,
|
||||
self::STATUS_ACTIVE,
|
||||
self::STATUS_PENDING,
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'site_code',
|
||||
'client_id',
|
||||
'name',
|
||||
'address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'is_active',
|
||||
'status',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
@@ -49,6 +73,7 @@ class Site extends Model
|
||||
|
||||
protected $attributes = [
|
||||
'is_active' => true,
|
||||
'status' => self::STATUS_UNREGISTERED,
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
@@ -71,6 +96,14 @@ public function updater(): BelongsTo
|
||||
return $this->belongsTo(User::class, 'updated_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래처
|
||||
*/
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 헬퍼 메서드
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user