mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-10 19:41:07 +03:30
change GetInputs api
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\Input;
|
||||
use App\Models\Option;
|
||||
use App\Models\TestResult;
|
||||
use App\Models\TestType;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Milon\Barcode\Facades\DNS1DFacade;
|
||||
@@ -380,20 +381,13 @@ class TestTypeController extends Controller
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function getInputs(Request $request)
|
||||
public function getInputs(int $testTypeId)
|
||||
{
|
||||
if (auth('api')->user()->can('getInputs')) {
|
||||
return MessageResponse::error(trans('messages.failed'));
|
||||
}
|
||||
if ($request->test_result_id !== '') {
|
||||
$testTypeId = TestResult::find($request->test_result_id);
|
||||
}
|
||||
if (isset($testTypeId) && $testTypeId) {
|
||||
$testType = TestType::select('id', 'name', 'unique_code', 'device_label')->find($testTypeId->test_type_id);
|
||||
} else {
|
||||
$testType = TestType::where('name', $request->name)->orWhere('unique_code', $request->unique_code)->select('id', 'name', 'unique_code', 'device_label')->first();
|
||||
}
|
||||
if (isset($testType) && $testType) {
|
||||
try {
|
||||
$testType = TestType::select('id', 'name', 'unique_code', 'device_label')->findOrFail($testTypeId);
|
||||
|
||||
$inputs = Input::select('id', 'name', 'type', 'size', 'parent_id', 'require_scanner')->with(
|
||||
['options' => function ($query) {
|
||||
@@ -408,8 +402,9 @@ class TestTypeController extends Controller
|
||||
)->whereNull('parent_id')->where('test_type_id', $testType->id)->get();
|
||||
|
||||
return MessageResponse::data(['testType' => $testType, 'inputs' => $inputs]);
|
||||
} catch(Exception $e) {
|
||||
return MessageResponse::error();
|
||||
}
|
||||
return MessageResponse::error();
|
||||
}
|
||||
|
||||
public function list()
|
||||
|
||||
Reference in New Issue
Block a user