change TestType & TestResult

This commit is contained in:
Fayyazi
2019-07-15 13:41:05 +04:30
parent d3735c6d30
commit 969f8b8b45
7 changed files with 91 additions and 35 deletions
+43 -19
View File
@@ -85,7 +85,10 @@ class TestResultController extends Controller
$TestResult = [
'user_id' => auth('api')->user()->id,
'autoclave_id' => $request->autoclave_id,
// 'autoclave_id' => $request->autoclave_id,
'cycle_number' => $request->cycle_number,
'device_id' => $request->device_id,
'device_label' => $request->device_label,
'test_type_id' => $request->test_type_id,
'result' => $request->result,
'verified' => 'NotVerified',
@@ -99,7 +102,7 @@ class TestResultController extends Controller
foreach ($Inputs as $Input) {
if ($Input['type'] != 'Form') {
$Value = $TestResultInfo[$Input->name.'_'.$Input->id];
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' ) {
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
// foreach ($Value as $Option) {
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $Input->id, 'option_id' => $Option]);
@@ -117,7 +120,7 @@ class TestResultController extends Controller
foreach ($Input->children as $InputChild) {
$Value = $TestResultInfo[$InputChild->name.'_'.$InputChild->id];
if ($InputChild['type'] == 'Checkbox' || $InputChild['type'] == 'Select') {
if ($InputChild['type'] == 'Checkbox' || $InputChild['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
// foreach ($Value as $Option) {
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $InputChild->id, 'option_id' => $Option]);
// }
@@ -138,20 +141,38 @@ class TestResultController extends Controller
///////////////////////////////////////////////////////////////////////////Inputs
///////////////////////////////////////////////////////////////////////////Image
if ($request->img != null) {
// if ($request->img != null) {
//
// $Image = $request->img;
// $InterventionImage = Image::make($Image);
// $Mime = explode('/', $InterventionImage->mime());
//
// $ImageName = time().'.'.$Mime[1];
// $Path = 'uploads'.'/TestResults'.'/'.$TestResultObj->id .'/'.$ImageName;
//
// Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResultObj->id);
// $InterventionImage->save(public_path($Path));
//
// $GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, 'path' => $Path]);
// $Uploadable = Uploadable::create(['uploadable_id' => $TestResultObj->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']);
// }
//-------------------------------------------------imgs
if ($request->imgs != null) {
$Image = $request->img;
$InterventionImage = Image::make($Image);
$Mime = explode('/', $InterventionImage->mime());
foreach ($request->imgs as $img) {
$Image = $img;
$InterventionImage = Image::make($Image);
$Mime = explode('/', $InterventionImage->mime());
$ImageName = time().'.'.$Mime[1];
$Path = 'uploads'.'/TestResults'.'/'.$TestResultObj->id .'/'.$ImageName;
$ImageName = time().'.'.$Mime[1];
$Path = 'uploads'.'/TestResults'.'/'.$TestResultObj->id .'/'.$ImageName;
Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResultObj->id);
$InterventionImage->save(public_path($Path));
Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResultObj->id);
$InterventionImage->save(public_path($Path));
$GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, 'path' => $Path]);
$Uploadable = Uploadable::create(['uploadable_id' => $TestResultObj->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']);
$GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, 'path' => $Path]);
$Uploadable = Uploadable::create(['uploadable_id' => $TestResultObj->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']);
}
}
///////////////////////////////////////////////////////////////////////////Image
@@ -172,7 +193,7 @@ class TestResultController extends Controller
if ($input->parent_id != null && $input->parent['type'] == 'Form') {
//----------------------------------------------------------------------FormType
if ($input->type == 'Checkbox' || $input->type == 'Select') {
if ($input->type == 'Checkbox' || $input->type == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
$options = [];
foreach ($input_options as $input_option) {
@@ -192,7 +213,7 @@ class TestResultController extends Controller
}
else {
//-----------------------------------------------------------------------Anothertype
if ($input->type == 'Checkbox' || $input->type == 'Select') {
if ($input->type == 'Checkbox' || $input->type == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
$options = [];
foreach ($input_options as $input_option) {
@@ -220,7 +241,7 @@ class TestResultController extends Controller
{
foreach ($TestResult->input_values as $key => $value) {
$input = $value->input;
if ($input->type == 'Checkbox' || $input->type == 'Select') {
if ($input->type == 'Checkbox' || $input->type == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
$input_options = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get()->pluck('option_id')->toArray();
$TestResult[$input->name.'_'.$input->id] = $input_options;
}
@@ -245,7 +266,10 @@ class TestResultController extends Controller
public function update(StoreTestResultRequest $request, TestResult $TestResult)
{
$TestResultData = [
'autoclave_id' => $request->autoclave_id,
// 'autoclave_id' => $request->autoclave_id,
'cycle_number' => $request->cycle_number,
'device_id' => $request->device_id,
'device_label' => $request->device_label,
'test_type_id' => $request->test_type_id,
'result' => $request->result,
'verified' => 'NotVerified',
@@ -259,7 +283,7 @@ class TestResultController extends Controller
if ($Input['type'] != 'Form') {
$Value = $TestResultInfo[$Input->name.'_'.$Input->id];
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' ) {
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
$InputOptions = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $Input->id)->get()->each->delete();
@@ -282,7 +306,7 @@ class TestResultController extends Controller
$Value = $TestResultInfo[$InputChild->name.'_'.$InputChild->id];
if ($InputChild['type'] == 'Checkbox' || $InputChild['type'] == 'Select') {
if ($InputChild['type'] == 'Checkbox' || $InputChild['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
$InputOptions = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $InputChild->id)->get()->each->delete();
// foreach ($Value as $Option) {