Skip to content

Commit

Permalink
Merge pull request #14530 from DrekiDegga/develop
Browse files Browse the repository at this point in the history
Added #14426: Makes all Manufacturer links dynamic, not just warranty lookup
  • Loading branch information
snipe authored Jul 19, 2024
2 parents 7773d33 + c50ab1a commit b7ab8b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/Models/Manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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://'
];

Expand Down
7 changes: 3 additions & 4 deletions app/Presenters/AssetPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
21 changes: 11 additions & 10 deletions resources/views/hardware/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,31 +299,32 @@
<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>
@endif

@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>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7ab8b9

Please sign in to comment.