mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 13:21:08 +03:30
Merge branch 'master' of https://gitlab.com/Saeid74/cssd
This commit is contained in:
@@ -85,7 +85,10 @@ class TestResultController extends Controller
|
|||||||
|
|
||||||
$TestResult = [
|
$TestResult = [
|
||||||
'user_id' => auth('api')->user()->id,
|
'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,
|
'test_type_id' => $request->test_type_id,
|
||||||
'result' => $request->result,
|
'result' => $request->result,
|
||||||
'verified' => 'NotVerified',
|
'verified' => 'NotVerified',
|
||||||
@@ -99,7 +102,7 @@ class TestResultController extends Controller
|
|||||||
foreach ($Inputs as $Input) {
|
foreach ($Inputs as $Input) {
|
||||||
if ($Input['type'] != 'Form') {
|
if ($Input['type'] != 'Form') {
|
||||||
$Value = $TestResultInfo[$Input->name.'_'.$Input->id];
|
$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) {
|
// foreach ($Value as $Option) {
|
||||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $Input->id, 'option_id' => $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) {
|
foreach ($Input->children as $InputChild) {
|
||||||
$Value = $TestResultInfo[$InputChild->name.'_'.$InputChild->id];
|
$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) {
|
// foreach ($Value as $Option) {
|
||||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $InputChild->id, 'option_id' => $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
|
///////////////////////////////////////////////////////////////////////////Inputs
|
||||||
///////////////////////////////////////////////////////////////////////////Image
|
///////////////////////////////////////////////////////////////////////////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;
|
foreach ($request->imgs as $img) {
|
||||||
$InterventionImage = Image::make($Image);
|
$Image = $img;
|
||||||
$Mime = explode('/', $InterventionImage->mime());
|
$InterventionImage = Image::make($Image);
|
||||||
|
$Mime = explode('/', $InterventionImage->mime());
|
||||||
|
|
||||||
$ImageName = time().'.'.$Mime[1];
|
$ImageName = time().'.'.$Mime[1];
|
||||||
$Path = 'uploads'.'/TestResults'.'/'.$TestResultObj->id .'/'.$ImageName;
|
$Path = 'uploads'.'/TestResults'.'/'.$TestResultObj->id .'/'.$ImageName;
|
||||||
|
|
||||||
Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResultObj->id);
|
Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResultObj->id);
|
||||||
$InterventionImage->save(public_path($Path));
|
$InterventionImage->save(public_path($Path));
|
||||||
|
|
||||||
$GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, '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']);
|
$Uploadable = Uploadable::create(['uploadable_id' => $TestResultObj->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////Image
|
///////////////////////////////////////////////////////////////////////////Image
|
||||||
|
|
||||||
@@ -172,7 +193,7 @@ class TestResultController extends Controller
|
|||||||
|
|
||||||
if ($input->parent_id != null && $input->parent['type'] == 'Form') {
|
if ($input->parent_id != null && $input->parent['type'] == 'Form') {
|
||||||
//----------------------------------------------------------------------FormType
|
//----------------------------------------------------------------------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();
|
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ($input_options as $input_option) {
|
foreach ($input_options as $input_option) {
|
||||||
@@ -192,7 +213,7 @@ class TestResultController extends Controller
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//-----------------------------------------------------------------------Anothertype
|
//-----------------------------------------------------------------------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();
|
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ($input_options as $input_option) {
|
foreach ($input_options as $input_option) {
|
||||||
@@ -220,7 +241,7 @@ class TestResultController extends Controller
|
|||||||
{
|
{
|
||||||
foreach ($TestResult->input_values as $key => $value) {
|
foreach ($TestResult->input_values as $key => $value) {
|
||||||
$input = $value->input;
|
$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();
|
$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;
|
$TestResult[$input->name.'_'.$input->id] = $input_options;
|
||||||
}
|
}
|
||||||
@@ -245,7 +266,10 @@ class TestResultController extends Controller
|
|||||||
public function update(StoreTestResultRequest $request, TestResult $TestResult)
|
public function update(StoreTestResultRequest $request, TestResult $TestResult)
|
||||||
{
|
{
|
||||||
$TestResultData = [
|
$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,
|
'test_type_id' => $request->test_type_id,
|
||||||
'result' => $request->result,
|
'result' => $request->result,
|
||||||
'verified' => 'NotVerified',
|
'verified' => 'NotVerified',
|
||||||
@@ -259,7 +283,7 @@ class TestResultController extends Controller
|
|||||||
if ($Input['type'] != 'Form') {
|
if ($Input['type'] != 'Form') {
|
||||||
$Value = $TestResultInfo[$Input->name.'_'.$Input->id];
|
$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();
|
$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];
|
$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();
|
$InputOptions = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $InputChild->id)->get()->each->delete();
|
||||||
|
|
||||||
// foreach ($Value as $Option) {
|
// foreach ($Value as $Option) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class TestTypeController extends Controller
|
|||||||
$InputObj = Input::create($InputData);
|
$InputObj = Input::create($InputData);
|
||||||
//---------------------------------------------Input
|
//---------------------------------------------Input
|
||||||
//---------------------------------------------Option
|
//---------------------------------------------Option
|
||||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select') {
|
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
|
||||||
foreach ($Input['options'] as $Option) {
|
foreach ($Input['options'] as $Option) {
|
||||||
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $InputObj->id]);
|
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $InputObj->id]);
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ class TestTypeController extends Controller
|
|||||||
];
|
];
|
||||||
//------------------------------------------------------Input
|
//------------------------------------------------------Input
|
||||||
//------------------------------------------------------Option
|
//------------------------------------------------------Option
|
||||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select') {
|
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
|
||||||
|
|
||||||
foreach ($Input['options'] as $Option) {
|
foreach ($Input['options'] as $Option) {
|
||||||
$OptionInfo = [
|
$OptionInfo = [
|
||||||
@@ -230,7 +230,7 @@ class TestTypeController extends Controller
|
|||||||
$InputObj = Input::findOrFail($Input['id']);
|
$InputObj = Input::findOrFail($Input['id']);
|
||||||
//---------------------------------------------Input
|
//---------------------------------------------Input
|
||||||
//---------------------------------------------Option
|
//---------------------------------------------Option
|
||||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select') {
|
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
|
||||||
|
|
||||||
|
|
||||||
//**************************
|
//**************************
|
||||||
|
|||||||
@@ -26,14 +26,12 @@ class StoreTestResultRequest extends FormRequest
|
|||||||
case 'POST': {
|
case 'POST': {
|
||||||
return [
|
return [
|
||||||
// 'user_id' => 'required',
|
// 'user_id' => 'required',
|
||||||
'autoclave_id' => 'required',
|
// 'autoclave_id' => 'required',
|
||||||
|
'device_id' => 'required',
|
||||||
|
'device_label' => 'required',
|
||||||
|
'cycle_number' => 'required',
|
||||||
'test_type_id' => 'required|numeric|exists:test_types,id',
|
'test_type_id' => 'required|numeric|exists:test_types,id',
|
||||||
'result' => 'required',
|
'result' => 'required',
|
||||||
// 'verified' => 'required',
|
|
||||||
// 'info.*.name'=>'required',
|
|
||||||
// 'info.*.type'=>'required',
|
|
||||||
// 'info.*.size'=>'nullable',
|
|
||||||
// 'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',
|
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -42,14 +40,12 @@ class StoreTestResultRequest extends FormRequest
|
|||||||
// $TestResult = $this->route('TestResult');
|
// $TestResult = $this->route('TestResult');
|
||||||
return [
|
return [
|
||||||
// 'user_id' => 'required',
|
// 'user_id' => 'required',
|
||||||
'autoclave_id' => 'required',
|
// 'autoclave_id' => 'required',
|
||||||
|
'device_id' => 'required',
|
||||||
|
'device_label' => 'required',
|
||||||
|
'cycle_number' => 'required',
|
||||||
'test_type_id' => 'required|numeric|exists:test_types,id',
|
'test_type_id' => 'required|numeric|exists:test_types,id',
|
||||||
'result' => 'required',
|
'result' => 'required',
|
||||||
// 'verified' => 'required',
|
|
||||||
// 'info.*.name'=>'required',
|
|
||||||
// 'info.*.type'=>'required',
|
|
||||||
// 'info.*.size'=>'nullable',
|
|
||||||
// 'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',
|
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Item extends Model
|
||||||
|
{
|
||||||
|
public $fillable = [];
|
||||||
|
public function packages()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany('App\Package', 'item_package');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Schema::create('role_user', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
// $table->integer('user_id')->unsigned();
|
||||||
|
//
|
||||||
|
// $table->integer('role_id')->unsigned();
|
||||||
|
//
|
||||||
|
// $table->foreign('user_id')->references('id')->on('users')
|
||||||
|
//
|
||||||
|
// ->onDelete('cascade');
|
||||||
|
//
|
||||||
|
// $table->foreign('role_id')->references('id')->on('roles')
|
||||||
|
//
|
||||||
|
// ->onDelete('cascade');
|
||||||
|
//
|
||||||
|
// });
|
||||||
@@ -11,5 +11,9 @@ class Package extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo('App\User');
|
return $this->belongsTo('App\User');
|
||||||
}
|
}
|
||||||
|
public function items()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany('App\Item', 'item_package');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class TestResult extends Model
|
class TestResult extends Model
|
||||||
{
|
{
|
||||||
public $fillable = ['result','verified','autoclave_id','test_type_id','user_id'];
|
public $fillable = ['result','verified','autoclave_id','test_type_id','user_id','device_id', 'device_label', 'cycle_number'];
|
||||||
public function test_type()
|
public function test_type()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\TestType');
|
return $this->belongsTo('App\TestType');
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ class CreateTestResultsTable extends Migration
|
|||||||
Schema::create('test_results', function (Blueprint $table) {
|
Schema::create('test_results', function (Blueprint $table) {
|
||||||
$table->bigIncrements('id');
|
$table->bigIncrements('id');
|
||||||
$table->string('info');
|
$table->string('info');
|
||||||
|
$table->string('cycle_number');
|
||||||
$table->string('result');
|
$table->string('result');
|
||||||
$table->text('description');
|
$table->text('description');
|
||||||
$table->smallInteger('verified');
|
$table->smallInteger('verified');
|
||||||
|
$table->string('device_id');
|
||||||
|
$table->string('device_label');
|
||||||
$table->integer('autoclave_id');
|
$table->integer('autoclave_id');
|
||||||
$table->unsignedBigInteger('user_id');
|
$table->unsignedBigInteger('user_id');
|
||||||
$table->foreign('user_id')->references('id')->on('users');
|
$table->foreign('user_id')->references('id')->on('users');
|
||||||
|
|||||||
Reference in New Issue
Block a user