|
@@ -23,14 +23,15 @@ class PricingCodeController extends Controller
|
|
|
|
|
|
|
|
public function index(Request $request)
|
|
public function index(Request $request)
|
|
|
{
|
|
{
|
|
|
|
|
+ session(['gp_pricing_codes' => $request->query()]);
|
|
|
$this->setSortAndOrderBy(new PricingCode(), $request);
|
|
$this->setSortAndOrderBy(new PricingCode(), $request);
|
|
|
|
|
|
|
|
- $sortBy = $request->get('sortBy', 'code');
|
|
|
|
|
|
|
+ $sortBy = $this->data['sortBy'] ?? 'code';
|
|
|
$allowedSort = ['id', 'type', 'code', 'description'];
|
|
$allowedSort = ['id', 'type', 'code', 'description'];
|
|
|
if (!in_array($sortBy, $allowedSort, true)) {
|
|
if (!in_array($sortBy, $allowedSort, true)) {
|
|
|
$sortBy = 'code';
|
|
$sortBy = 'code';
|
|
|
}
|
|
}
|
|
|
- $orderBy = $request->get('order') === 'desc' ? 'desc' : 'asc';
|
|
|
|
|
|
|
+ $orderBy = $this->data['orderBy'] ?? 'asc';
|
|
|
|
|
|
|
|
$q = PricingCode::query();
|
|
$q = PricingCode::query();
|
|
|
|
|
|
|
@@ -72,13 +73,13 @@ class PricingCodeController extends Controller
|
|
|
->exists();
|
|
->exists();
|
|
|
|
|
|
|
|
if ($exists) {
|
|
if ($exists) {
|
|
|
- return redirect()->route('pricing_codes.index')
|
|
|
|
|
|
|
+ return redirect()->route('pricing_codes.index', session('gp_pricing_codes', []))
|
|
|
->with(['error' => 'Такой код уже существует для данного типа!']);
|
|
->with(['error' => 'Такой код уже существует для данного типа!']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PricingCode::create($request->only(['type', 'code', 'description']));
|
|
PricingCode::create($request->only(['type', 'code', 'description']));
|
|
|
|
|
|
|
|
- return redirect()->route('pricing_codes.index')
|
|
|
|
|
|
|
+ return redirect()->route('pricing_codes.index', session('gp_pricing_codes', []))
|
|
|
->with(['success' => 'Код расценки успешно добавлен!']);
|
|
->with(['success' => 'Код расценки успешно добавлен!']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -90,7 +91,7 @@ class PricingCodeController extends Controller
|
|
|
|
|
|
|
|
$pricingCode->update(['description' => $request->get('description')]);
|
|
$pricingCode->update(['description' => $request->get('description')]);
|
|
|
|
|
|
|
|
- return redirect()->route('pricing_codes.index')
|
|
|
|
|
|
|
+ return redirect()->route('pricing_codes.index', session('gp_pricing_codes', []))
|
|
|
->with(['success' => 'Расшифровка успешно обновлена!']);
|
|
->with(['success' => 'Расшифровка успешно обновлена!']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -98,7 +99,7 @@ class PricingCodeController extends Controller
|
|
|
{
|
|
{
|
|
|
$pricingCode->delete();
|
|
$pricingCode->delete();
|
|
|
|
|
|
|
|
- return redirect()->route('pricing_codes.index')
|
|
|
|
|
|
|
+ return redirect()->route('pricing_codes.index', session('gp_pricing_codes', []))
|
|
|
->with(['success' => 'Код расценки успешно удалён!']);
|
|
->with(['success' => 'Код расценки успешно удалён!']);
|
|
|
}
|
|
}
|
|
|
|
|
|