|
|
@@ -3,10 +3,12 @@
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use App\Http\Requests\CreateReclamationRequest;
|
|
|
+use App\Http\Requests\StoreReclamationDetailsRequest;
|
|
|
use App\Http\Requests\StoreReclamationRequest;
|
|
|
use App\Models\File;
|
|
|
use App\Models\Order;
|
|
|
use App\Models\Reclamation;
|
|
|
+use App\Models\ReclamationDetail;
|
|
|
use App\Models\ReclamationStatus;
|
|
|
use App\Models\Role;
|
|
|
use App\Models\User;
|
|
|
@@ -18,21 +20,21 @@ use Illuminate\Support\Facades\Storage;
|
|
|
class ReclamationController extends Controller
|
|
|
{
|
|
|
protected array $data = [
|
|
|
- 'active' => 'reclamations',
|
|
|
- 'title' => 'Рекламации',
|
|
|
- 'id' => 'reclamations',
|
|
|
- 'header' => [
|
|
|
- 'id' => 'ID',
|
|
|
- 'user_id' => 'Менеджер',
|
|
|
- 'status_id' => 'Статус',
|
|
|
- 'order-district_id' => 'Округ',
|
|
|
- 'order-area_id' => 'Район',
|
|
|
- 'order-object_address' => 'Адрес объекта',
|
|
|
- 'create_date' => 'Дата создания',
|
|
|
- 'finish_date' => 'Дата завершения',
|
|
|
- 'reason' => 'Причина',
|
|
|
- 'guarantee' => 'Гарантии',
|
|
|
- 'whats_done' => 'Что сделано',
|
|
|
+ 'active' => 'reclamations',
|
|
|
+ 'title' => 'Рекламации',
|
|
|
+ 'id' => 'reclamations',
|
|
|
+ 'header' => [
|
|
|
+ 'id' => 'ID',
|
|
|
+ 'user_id' => 'Менеджер',
|
|
|
+ 'status_id' => 'Статус',
|
|
|
+ 'order-district_id' => 'Округ',
|
|
|
+ 'order-area_id' => 'Район',
|
|
|
+ 'order-object_address' => 'Адрес объекта',
|
|
|
+ 'create_date' => 'Дата создания',
|
|
|
+ 'finish_date' => 'Дата завершения',
|
|
|
+ 'reason' => 'Причина',
|
|
|
+ 'guarantee' => 'Гарантии',
|
|
|
+ 'whats_done' => 'Что сделано',
|
|
|
],
|
|
|
'searchFields' => [
|
|
|
'reason',
|
|
|
@@ -101,7 +103,7 @@ class ReclamationController extends Controller
|
|
|
]);
|
|
|
$f = [];
|
|
|
foreach ($data['photo'] as $photo) {
|
|
|
- $f[] = $fileService->saveUploadedFile( 'reclamations/' . $reclamation->id . '/photo_before', $photo);
|
|
|
+ $f[] = $fileService->saveUploadedFile('reclamations/' . $reclamation->id . '/photo_before', $photo);
|
|
|
}
|
|
|
$reclamation->photos_before()->syncWithoutDetaching($f);
|
|
|
|
|
|
@@ -115,7 +117,7 @@ class ReclamationController extends Controller
|
|
|
]);
|
|
|
$f = [];
|
|
|
foreach ($data['photo'] as $photo) {
|
|
|
- $f[] = $fileService->saveUploadedFile( 'reclamations/' . $reclamation->id . '/photo_after', $photo);
|
|
|
+ $f[] = $fileService->saveUploadedFile('reclamations/' . $reclamation->id . '/photo_after', $photo);
|
|
|
}
|
|
|
$reclamation->photos_after()->syncWithoutDetaching($f);
|
|
|
|
|
|
@@ -145,7 +147,7 @@ class ReclamationController extends Controller
|
|
|
]);
|
|
|
$f = [];
|
|
|
foreach ($data['document'] as $document) {
|
|
|
- $f[] = $fileService->saveUploadedFile( 'reclamations/' . $reclamation->id . '/document', $document);
|
|
|
+ $f[] = $fileService->saveUploadedFile('reclamations/' . $reclamation->id . '/document', $document);
|
|
|
}
|
|
|
$reclamation->documents()->syncWithoutDetaching($f);
|
|
|
|
|
|
@@ -167,7 +169,7 @@ class ReclamationController extends Controller
|
|
|
]);
|
|
|
$f = [];
|
|
|
foreach ($data['acts'] as $document) {
|
|
|
- $f[] = $fileService->saveUploadedFile( 'reclamations/' . $reclamation->id . '/act', $document);
|
|
|
+ $f[] = $fileService->saveUploadedFile('reclamations/' . $reclamation->id . '/act', $document);
|
|
|
}
|
|
|
$reclamation->acts()->syncWithoutDetaching($f);
|
|
|
|
|
|
@@ -182,4 +184,29 @@ class ReclamationController extends Controller
|
|
|
return redirect()->route('reclamations.show', $reclamation);
|
|
|
}
|
|
|
|
|
|
+ public function updateDetails(StoreReclamationDetailsRequest $request, Reclamation $reclamation)
|
|
|
+ {
|
|
|
+ $names = $request->validated('name');
|
|
|
+ $quantity = $request->validated('quantity');
|
|
|
+ foreach ($names as $key => $name) {
|
|
|
+ if(!$name) continue;
|
|
|
+ if ((int)$quantity[$key] > 1) {
|
|
|
+ ReclamationDetail::query()
|
|
|
+ ->updateOrCreate([
|
|
|
+ 'reclamation_id' => $reclamation->id,
|
|
|
+ 'name' => $name,
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'quantity' => $quantity[$key],
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ ReclamationDetail::query()
|
|
|
+ ->where('reclamation_details.reclamation_id', $reclamation->id)
|
|
|
+ ->where('reclamation_details.name', $name)
|
|
|
+ ->delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return redirect()->route('reclamations.show', $reclamation);
|
|
|
+ }
|
|
|
+
|
|
|
}
|