From 16a5a883e532fb4eea229a2dc95c015483f78763 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 20 Apr 2023 16:34:25 -0400 Subject: [PATCH] new request, preparing support_url for validation --- .../Controllers/ManufacturersController.php | 5 ++- app/Http/Requests/SaveManufacturerRequest.php | 41 +++++++++++++++++++ app/Presenters/AssetPresenter.php | 14 +++++++ resources/views/hardware/view.blade.php | 2 +- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 app/Http/Requests/SaveManufacturerRequest.php diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index 1f7d2f2c07..6e024ab8a6 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Requests\ImageUploadRequest; +use App\Http\Requests\SaveManufacturerRequest; use App\Models\Manufacturer; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -114,7 +115,7 @@ class ManufacturersController extends Controller * @since [v1.0] * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function update(ImageUploadRequest $request, $manufacturerId = null) + public function update(SaveManufacturerRequest $request, $manufacturerId = null) { $this->authorize('update', Manufacturer::class); // Check if the manufacturer exists @@ -123,7 +124,7 @@ class ManufacturersController extends Controller return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.does_not_exist')); } - // Save the data + // Save the data $manufacturer->name = $request->input('name'); $manufacturer->url = $request->input('url'); $manufacturer->support_url = $request->input('support_url'); diff --git a/app/Http/Requests/SaveManufacturerRequest.php b/app/Http/Requests/SaveManufacturerRequest.php new file mode 100644 index 0000000000..dc96042e09 --- /dev/null +++ b/app/Http/Requests/SaveManufacturerRequest.php @@ -0,0 +1,41 @@ +getRules(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation() + { + $this->merge([ + 'support_url' => $this->input('support_url'), + ]); + dd($this->all()); + } +} diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 4be0f56010..06364fe31a 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -534,6 +534,20 @@ class AssetPresenter extends Presenter return false; } + /** + * Used to take user created warranty URL and dynamically fill in the needed values per asset + * @return string + */ + public function supportUrl() + { + $tempurl = $this->model->model->manufacturer->support_url; + + $tempurl = (str_replace('{LOCALE}',\App\Models\Setting::getSettings()->locale,$tempurl)); + $tempurl = (str_replace('{SERIAL}',$this->model->serial,$tempurl)); + + return $tempurl; + } + /** * Url to view this item. * @return string diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index b5f61cf2c7..c4510adee6 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -596,7 +596,7 @@ {{ trans('admin/hardware/form.months') }} @if ($asset->serial && $asset->model->manufacturer) - + {{ trans('hardware/general.mfg_warranty_lookup') }} @endif