diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index 5408d50c36c9..85907f7ddbab 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -22,9 +22,9 @@ class Manufacturer extends SnipeModel // Declare the rules for the form validation protected $rules = [ 'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL', - 'url' => 'url|nullable', + 'url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://', 'support_email' => 'email|nullable', - 'support_url' => 'nullable|url', + 'support_url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://', 'warranty_lookup_url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://' ]; diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 163ee1b606b5..b86135f33b8d 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -556,13 +556,12 @@ public function warranty_expires() } /** - * Used to take user created warranty URL and dynamically fill in the needed values per asset + * Used to take user created URL and dynamically fill in the needed values per asset * @return string */ - public function dynamicWarrantyUrl() + public function dynamicUrl($dynamic_url) { - $warranty_lookup_url = $this->model->model->manufacturer->warranty_lookup_url; - $url = (str_replace('{LOCALE}',\App\Models\Setting::getSettings()->locale, $warranty_lookup_url)); + $url = (str_replace('{LOCALE}',\App\Models\Setting::getSettings()->locale, $dynamic_url)); $url = (str_replace('{SERIAL}', urlencode($this->model->serial), $url)); $url = (str_replace('{MODEL_NAME}', urlencode($this->model->model->name), $url)); $url = (str_replace('{MODEL_NUMBER}', urlencode($this->model->model->model_number), $url)); diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 461f2a4688ea..1372fbea8758 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -281,21 +281,21 @@
  • {{ $asset->model->manufacturer->name }}
  • @endcan - @if (($asset->model) && ($asset->model->manufacturer->url)) + @if (($asset->model->manufacturer) && ($asset->model->manufacturer->url!=''))
  • - - {{ $asset->model->manufacturer->url }} + + {{ $asset->present()->dynamicUrl($asset->model->manufacturer->url) }}
  • @endif - @if (($asset->model) && ($asset->model->manufacturer->support_url)) + @if (($asset->model->manufacturer) && ($asset->model->manufacturer->support_url!=''))
  • - - {{ $asset->model->manufacturer->support_url }} + + {{ $asset->present()->dynamicUrl($asset->model->manufacturer->support_url) }}
  • @@ -304,8 +304,8 @@ @if (($asset->model->manufacturer) && ($asset->model->manufacturer->warranty_lookup_url!=''))
  • - - {{ $asset->present()->dynamicWarrantyUrl() }} + + {{ $asset->present()->dynamicUrl($asset->model->manufacturer->warranty_lookup_url) }}
  • @@ -575,7 +575,7 @@ {{ trans('admin/hardware/form.months') }} @if (($asset->model) && ($asset->model->manufacturer) && ($asset->model->manufacturer->warranty_lookup_url!='')) - + @endif