mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-11 14:41:06 +03:30
Forgot Password Back end
This commit is contained in:
@@ -38,6 +38,7 @@ class TestResultController extends Controller
|
||||
|
||||
public function store(StoreTestResultRequest $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
try {
|
||||
$return_value = \DB::transaction(function () use ($request) {
|
||||
|
||||
@@ -46,7 +47,7 @@ class TestResultController extends Controller
|
||||
'autoclave_id' => $request->autoclave_id,
|
||||
'test_type_id' => $request->test_type_id,
|
||||
'result' => $request->result,
|
||||
'verified' => 0,
|
||||
'verified' => 'NotVerified',
|
||||
];
|
||||
$TestResultObj = TestResult::create($TestResult);
|
||||
$TestResultInfo = $request->all();
|
||||
@@ -57,11 +58,17 @@ class TestResultController extends Controller
|
||||
foreach ($Inputs as $Input) {
|
||||
if ($Input['type'] != 'Form') {
|
||||
$Value = $TestResultInfo[$Input->name];
|
||||
if ($Input['type'] == 'Checkbox') {
|
||||
$Value = json_encode($Value);
|
||||
}
|
||||
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value]);
|
||||
}
|
||||
else {
|
||||
foreach ($Input->children as $InputChild) {
|
||||
$Value = $TestResultInfo[$Input->name][$InputChild->name];
|
||||
$Value = $TestResultInfo[$InputChild->name];
|
||||
if ($InputChild['type'] == 'Checkbox') {
|
||||
$Value = json_encode($Value);
|
||||
}
|
||||
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'value' => $Value]);
|
||||
}
|
||||
//-------------------------------------------------------
|
||||
@@ -107,9 +114,13 @@ class TestResultController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
//Todo:: pass Inputs
|
||||
//Todo:: pass Inputs
|
||||
public function edit(TestResult $TestResult)
|
||||
{
|
||||
foreach ($TestResult->input_values as $key => $value) {
|
||||
$input = $value->input;
|
||||
$TestResult[$input->name] = $value->value;
|
||||
}
|
||||
return \MessageResponse::data($TestResult);
|
||||
}
|
||||
|
||||
@@ -120,7 +131,7 @@ class TestResultController extends Controller
|
||||
'autoclave_id' => $request->autoclave_id,
|
||||
'test_type_id' => $request->test_type_id,
|
||||
'result' => $request->result,
|
||||
'verified' => 0,
|
||||
'verified' => 'NotVerified',
|
||||
];
|
||||
$TestResult->update($TestResultData);
|
||||
$TestResultInfo = $request->all();
|
||||
@@ -130,20 +141,46 @@ class TestResultController extends Controller
|
||||
foreach ($Inputs as $Input) {
|
||||
if ($Input['type'] != 'Form') {
|
||||
$Value = $TestResultInfo[$Input->name];
|
||||
$InputValueObj = InputValue::where('test_result_id',$TestResult)->update(['test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value]);
|
||||
if ($Input['type'] == 'Checkbox') {
|
||||
$Value = json_encode($Value);
|
||||
}
|
||||
|
||||
$InputValueObj = InputValue::where('test_result_id',$TestResult->id)->where('input_id', $Input['id'])->update(['value' => $Value]);
|
||||
}
|
||||
else {
|
||||
foreach ($Input->children as $InputChild) {
|
||||
$Value = $TestResultInfo[$Input->name][$InputChild->name];
|
||||
$InputValueObj = InputValue::where('test_result_id',$TestResult)->update(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'value' => $Value]);
|
||||
$Value = $TestResultInfo[$InputChild->name];
|
||||
if ($InputChild['type'] == 'Checkbox') {
|
||||
$Value = json_encode($Value);
|
||||
}
|
||||
$InputValueObj = InputValue::where('test_result_id',$TestResult->id)->where('input_id', $Input['id'])->update(['value' => $Value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return \MessageResponse::success(null,trans('messages.update'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
public function destroy(TestResult $TestResult)
|
||||
{
|
||||
//
|
||||
if (auth('api')->user()->can('delete', $TestResult)) {
|
||||
return \MessageResponse::error(trans('messages.failed'));
|
||||
}
|
||||
$TestResult->delete();
|
||||
return \MessageResponse::success(null, trans('messages.failed'));
|
||||
}
|
||||
|
||||
public function verifyTestResult(TestResult $TestResult)
|
||||
{
|
||||
if (auth('api')->user()->can('verifyTestResult', $TestResult)) {
|
||||
return \MessageResponse::error(trans('messages.failed'));
|
||||
}
|
||||
if ($TestResult->verified == 'Verified') {
|
||||
$TestResult->verified = 'NotVerified';
|
||||
} else {
|
||||
$TestResult->verified = 'Verified';
|
||||
}
|
||||
$TestResult->save();
|
||||
return \MessageResponse::data($TestResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user