new correction

This commit is contained in:
Fateme
2020-07-04 23:26:44 +04:30
parent a74e49af6f
commit 1f1be72d74
21 changed files with 161 additions and 107 deletions
+21 -21
View File
@@ -70,7 +70,7 @@ class TestResultController extends Controller
})
->when($request->has('device_id') && $request->device_id, function($query) use($request){
$device_label = $request->device_label ? $request->device_label : '';
if ($device_label){
if ($device_label && $device_label != 'undefined'){
$query->whereHas('input_values', function($query) use($request, $device_label){
$query->whereHas('input', function($query) use($request, $device_label){
$query->where('name', $device_label);
@@ -243,12 +243,12 @@ class TestResultController extends Controller
}
}
$ImagesPath = [];
if (count($TestResult->images)) {
foreach ($TestResult->images as $Key => $Image) {
$ImagesPath[] = $Image->path;
$FilesPath = [];
if (count($TestResult->files)) {
foreach ($TestResult->files as $Key => $File) {
$FilesPath[] = $File->path;
}
$TestResult['imagesPath'] = $ImagesPath;
$TestResult['filesPath'] = $FilesPath;
}
$TestResult['device_label'] = $TestResult->test_type->device_label;
return \MessageResponse::data($TestResult);
@@ -272,16 +272,16 @@ class TestResultController extends Controller
}
}
$ImagesPath = [];
$FilesPath = [];
if (count($TestResult->images)) {
foreach ($TestResult->images as $Key => $Image) {
$ImagesPath[] = $Image;
if (count($TestResult->files)) {
foreach ($TestResult->files as $Key => $file) {
$FilesPath[] = $file;
}
$TestResult['imagesPath'] = $ImagesPath;
$TestResult['filesPath'] = $FilesPath;
}
else {
$TestResult['imagesPath'] = [];
$TestResult['filesPath'] = [];
}
return \MessageResponse::data($TestResult);
@@ -364,10 +364,10 @@ class TestResultController extends Controller
if (count($TestResult->input_values)) {
InputValue::where('test_result_id', $TestResult->id)->get()->each->delete();
}
if (count($TestResult->images)){
foreach ($TestResult->images as $image) {
Storage::disk('public')->delete(static::storage_path($image->path));
Media::where('id', $image->id)->delete();
if (count($TestResult->files)){
foreach ($TestResult->files as $file) {
Storage::disk('public')->delete(static::storage_path($file->path));
Media::where('id', $file->id)->delete();
}
}
$TestResult->delete();
@@ -505,12 +505,12 @@ class TestResultController extends Controller
}
}
$ImagesPath = [];
if (count($TestResult->TitleImage)) {
foreach ($TestResult->TitleImage as $Key => $TitleImage) {
$ImagesPath[] = $TitleImage->path;
$FilesPath = [];
if (count($TestResult->files)) {
foreach ($TestResult->files as $Key => $File) {
$FilesPath[] = $File->path;
}
$TestResult['imagesPath'] = $ImagesPath;
$TestResult['filesPath'] = $FilesPath;
}
// dd($TestResult->test_type()->device_label);
$TestResult['device_label'] = $TestResult->test_type->device_label;