45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
namespace App\Repositories;
|
|
|
|
use App\Models\Estimates\MainRequestEstimate;
|
|
use App\Models\MainRequest;
|
|
use App\Models\MainRequestFlow;
|
|
use App\Models\MainRequestOrder;
|
|
|
|
class MainRequestRepository
|
|
{
|
|
// 메인 업무 단건 조회
|
|
public function find($id)
|
|
{
|
|
return MainRequest::with(['flows', 'estimates', 'orders'])->find($id);
|
|
}
|
|
|
|
// 견적 생성
|
|
public function createEstimate($mainRequestId, array $data)
|
|
{
|
|
$data['main_request_id'] = $mainRequestId;
|
|
return MainRequestEstimate::create($data);
|
|
}
|
|
|
|
// 주문 생성
|
|
public function createOrder($mainRequestId, array $data)
|
|
{
|
|
$data['main_request_id'] = $mainRequestId;
|
|
return MainRequestOrder::create($data);
|
|
}
|
|
|
|
// 이력(Flow) 기록
|
|
public function addFlow($mainRequestId, $flowableType, $flowableId, $status, $action, $actorId, $content = null)
|
|
{
|
|
return MainRequestFlow::create([
|
|
'main_request_id' => $mainRequestId,
|
|
'flowable_type' => $flowableType,
|
|
'flowable_id' => $flowableId,
|
|
'status_code' => $status,
|
|
'action' => $action,
|
|
'actor_id' => $actorId,
|
|
'content' => $content,
|
|
]);
|
|
}
|
|
}
|