mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
new request, preparing support_url for validation
This commit is contained in:
parent
0a993b2aa1
commit
16a5a883e5
|
@ -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');
|
||||
|
|
41
app/Http/Requests/SaveManufacturerRequest.php
Normal file
41
app/Http/Requests/SaveManufacturerRequest.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Manufacturer;
|
||||
|
||||
class SaveManufacturerRequest extends ImageUploadRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return parent::rules() + (new Manufacturer())->getRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'support_url' => $this->input('support_url'),
|
||||
]);
|
||||
dd($this->all());
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -596,7 +596,7 @@
|
|||
{{ trans('admin/hardware/form.months') }}
|
||||
|
||||
@if ($asset->serial && $asset->model->manufacturer)
|
||||
<a href="{{ (str_replace('_testlocale_',\App\Models\Setting::getSettings()->locale,$asset->model->manufacturer->support_url))}}" target="_blank">
|
||||
<a href="{{ $asset->present()->supportUrl() }}" target="_blank">
|
||||
<i class="fa fa-external-link" style="width:25px;height:25px;"><span class="sr-only">{{ trans('hardware/general.mfg_warranty_lookup') }}</span></i>
|
||||
</a>
|
||||
@endif
|
||||
|
|
Loading…
Reference in a new issue