Merge branch 'develop' of https://github.com/snipe/snipe-it into develop

This commit is contained in:
snipe 2024-07-19 19:07:53 +01:00
commit 8e03083b83
3 changed files with 16 additions and 16 deletions

View file

@ -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://'
];

View file

@ -556,13 +556,12 @@ class AssetPresenter extends Presenter
}
/**
* 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));

View file

@ -299,21 +299,21 @@
<li> {{ $asset->model->manufacturer->name }}</li>
@endcan
@if (($asset->model) && ($asset->model->manufacturer->url))
@if (($asset->model->manufacturer) && ($asset->model->manufacturer->url!=''))
<li>
<i class="fas fa-globe-americas" aria-hidden="true"></i>
<a href="{{ $asset->model->manufacturer->url }}" target="_blank">
{{ $asset->model->manufacturer->url }}
<a href="{{ $asset->present()->dynamicUrl($asset->model->manufacturer->url) }}" target="_blank">
{{ $asset->present()->dynamicUrl($asset->model->manufacturer->url) }}
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
</li>
@endif
@if (($asset->model) && ($asset->model->manufacturer->support_url))
@if (($asset->model->manufacturer) && ($asset->model->manufacturer->support_url!=''))
<li>
<i class="far fa-life-ring" aria-hidden="true"></i>
<a href="{{ $asset->model->manufacturer->support_url }}" target="_blank">
{{ $asset->model->manufacturer->support_url }}
<a href="{{ $asset->present()->dynamicUrl($asset->model->manufacturer->support_url) }}" target="_blank">
{{ $asset->present()->dynamicUrl($asset->model->manufacturer->support_url) }}
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
</li>
@ -321,9 +321,10 @@
@if (($asset->model->manufacturer) && ($asset->model->manufacturer->warranty_lookup_url!=''))
<li>
<i class="fa-solid fa-wrench" aria-hidden="true"></i>
<a href="{{ $asset->present()->dynamicWarrantyUrl() }}" target="_blank">
{{ $asset->present()->dynamicWarrantyUrl() }}
<i class="far fa-wrench" aria-hidden="true"></i>
<a href="{{ $asset->present()->dynamicUrl($asset->model->manufacturer->warranty_lookup_url) }}" target="_blank">
{{ $asset->present()->dynamicUrl($asset->model->manufacturer->warranty_lookup_url) }}
<i class="fa fa-external-link" aria-hidden="true"><span class="sr-only">{{ trans('admin/hardware/general.mfg_warranty_lookup', ['manufacturer' => $asset->model->manufacturer->name]) }}</span></i>
</a>
</li>
@ -598,7 +599,7 @@
{{ trans('admin/hardware/form.months') }}
@if (($asset->model) && ($asset->model->manufacturer) && ($asset->model->manufacturer->warranty_lookup_url!=''))
<a href="{{ $asset->present()->dynamicWarrantyUrl() }}" target="_blank">
<a href="{{ $asset->present()->dynamicUrl($asset->model->manufacturer->warranty_lookup_url) }}" target="_blank">
<i class="fa fa-external-link" aria-hidden="true"><span class="sr-only">{{ trans('admin/hardware/general.mfg_warranty_lookup', ['manufacturer' => $asset->model->manufacturer->name]) }}</span></i>
</a>
@endif