Skip to content

A free open source IT asset/license management system

Gate check linking in presenters

snipe686afc09742f
diff --git a/app/Presenters/AccessoryPresenter.php b/app/Presenters/AccessoryPresenter.php
index 57e03bb424..62d264e800 100644
--- a/app/Presenters/AccessoryPresenter.php
+++ b/app/Presenters/AccessoryPresenter.php
@@ -262,7 +262,11 @@ class AccessoryPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('accessories.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Accessory', $this])) {
+ return (string)link_to_route('accessories.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php
index 14b5a7c964..9eff9cceee 100644
--- a/app/Presenters/AssetPresenter.php
+++ b/app/Presenters/AssetPresenter.php
@@ -447,7 +447,11 @@ class AssetPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('hardware.show', e($this->name), $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Asset', $this])) {
+ return (string)link_to_route('hardware.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
public function modelUrl()
diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php
index 2b827dae68..ca0c2434af 100644
--- a/app/Presenters/CategoryPresenter.php
+++ b/app/Presenters/CategoryPresenter.php
@@ -139,7 +139,11 @@ class CategoryPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('categories.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Category', $this])) {
+ return (string)link_to_route('categories.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
@@ -157,6 +161,6 @@ class CategoryPresenter extends Presenter
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('categories.show', e($this->id)).'">'.e($this->name).'</a>';
}
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').e($this->name);
}
}
diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php
index bbb06bbafc..db29b0283a 100644
--- a/app/Presenters/CompanyPresenter.php
+++ b/app/Presenters/CompanyPresenter.php
@@ -164,7 +164,11 @@ class CompanyPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('companies.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Company', $this])) {
+ return (string)link_to_route('companies.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
@@ -179,9 +183,9 @@ class CompanyPresenter extends Presenter
public function formattedNameLink() {
if (auth()->user()->can('view', ['\App\Models\Company', $this])) {
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('companies.show', e($this->id)).'">'.e($this->name).'</a>';
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('companies.show', e($this->id)).'">'.e($this->display_name).'</a>';
}
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').$this->name;
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').e($this->display_name);
}
}
diff --git a/app/Presenters/ComponentPresenter.php b/app/Presenters/ComponentPresenter.php
index 9a5e354c55..852d91997f 100644
--- a/app/Presenters/ComponentPresenter.php
+++ b/app/Presenters/ComponentPresenter.php
@@ -197,7 +197,11 @@ class ComponentPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('consumables.show', e($this->name), $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Component', $this])) {
+ return (string)link_to_route('components.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
diff --git a/app/Presenters/CustomFieldsetPresenter.php b/app/Presenters/CustomFieldsetPresenter.php
new file mode 100644
index 0000000000..a5d4d64749
--- /dev/null
+++ b/app/Presenters/CustomFieldsetPresenter.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Presenters;
+
+/**
+ * Class CustomFieldsetPresenter
+ */
+class CustomFieldsetPresenter extends Presenter
+{
+
+
+ public function nameUrl()
+ {
+ if (auth()->user()->can('view', ['\App\Models\CustomFieldset', $this])) {
+ return (string)link_to_route('fieldsets.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
+ }
+
+
+}
diff --git a/app/Presenters/DepartmentPresenter.php b/app/Presenters/DepartmentPresenter.php
index ea3d051d4f..542d6b4d5a 100644
--- a/app/Presenters/DepartmentPresenter.php
+++ b/app/Presenters/DepartmentPresenter.php
@@ -118,6 +118,19 @@ class DepartmentPresenter extends Presenter
}
+ /**
+ * Url to view this item.
+ * @return string
+ */
+ public function viewUrl()
+ {
+ if (auth()->user()->can('view', ['\App\Models\Location', $this])) {
+ return (string)link_to_route('locations.show', $this->display_name, $this->id);
+ } else {
+ return $this->display_name;
+ }
+ }
+
public function formattedNameLink() {
if (auth()->user()->can('view', ['\App\Models\Department', $this])) {
diff --git a/app/Presenters/DepreciationPresenter.php b/app/Presenters/DepreciationPresenter.php
index a25643e934..f6d358827f 100644
--- a/app/Presenters/DepreciationPresenter.php
+++ b/app/Presenters/DepreciationPresenter.php
@@ -102,4 +102,17 @@ class DepreciationPresenter extends Presenter
return json_encode($layout);
}
+
+ public function formattedNameLink() {
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').e($this->display_name);
+ }
+
+ public function nameUrl()
+ {
+ if (auth()->user()->can('view', ['\App\Models\Depreciation', $this])) {
+ return (string)link_to_route('depreciations.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
+ }
}
diff --git a/app/Presenters/DepreciationReportPresenter.php b/app/Presenters/DepreciationReportPresenter.php
index 1d4c459614..c8332cccbf 100644
--- a/app/Presenters/DepreciationReportPresenter.php
+++ b/app/Presenters/DepreciationReportPresenter.php
@@ -180,7 +180,11 @@ class DepreciationReportPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('hardware.show', e($this->name), $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Depreciation', $this])) {
+ return (string)link_to_route('depreciations.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
public function modelUrl()
diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.php
index 460bdb81df..2ce939fce2 100644
--- a/app/Presenters/LocationPresenter.php
+++ b/app/Presenters/LocationPresenter.php
@@ -346,7 +346,11 @@ class LocationPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('locations.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Location', $this])) {
+ return (string)link_to_route('locations.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
@@ -367,6 +371,7 @@ class LocationPresenter extends Presenter
return route('locations.show', $this->id);
}
+
public function glyph()
{
return '<x-icon type="locations" />';
@@ -380,9 +385,9 @@ class LocationPresenter extends Presenter
public function formattedNameLink() {
if (auth()->user()->can('view', ['\App\Models\Location', $this])) {
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('locations.show', e($this->id)).'">'.e($this->name).'</a>';
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('locations.show', e($this->id)).'">'.e($this->display_name).'</a>';
}
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').e($this->display_name);
}
}
diff --git a/app/Presenters/ManufacturerPresenter.php b/app/Presenters/ManufacturerPresenter.php
index e4730adf36..2a0952b93c 100644
--- a/app/Presenters/ManufacturerPresenter.php
+++ b/app/Presenters/ManufacturerPresenter.php
@@ -180,7 +180,11 @@ class ManufacturerPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('manufacturers.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Manufacturer', $this])) {
+ return (string)link_to_route('manufacturers.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
@@ -195,10 +199,10 @@ class ManufacturerPresenter extends Presenter
public function formattedNameLink() {
if (auth()->user()->can('view', ['\App\Models\Manufacturer', $this])) {
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('manufacturers.show', e($this->id)).'">'.e($this->name).'</a>';
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('manufacturers.show', e($this->id)).'">'.e($this->display_name).'</a>';
}
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').e($this->display_name);
}
}
diff --git a/app/Presenters/PredefinedKitPresenter.php b/app/Presenters/PredefinedKitPresenter.php
index c8b8f1360d..92c49b6aa7 100644
--- a/app/Presenters/PredefinedKitPresenter.php
+++ b/app/Presenters/PredefinedKitPresenter.php
@@ -295,7 +295,12 @@ class PredefinedKitPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('kits.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\PredefinedKit', $this])) {
+ return (string)link_to_route('kits.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
+
}
/**
diff --git a/app/Presenters/SupplierPresenter.php b/app/Presenters/SupplierPresenter.php
index dd9d87d733..1aabc303e8 100644
--- a/app/Presenters/SupplierPresenter.php
+++ b/app/Presenters/SupplierPresenter.php
@@ -207,7 +207,11 @@ class SupplierPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('suppliers.show', $this->name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Supplier', $this])) {
+ return (string)link_to_route('suppliers.show', e($this->display_name), $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
/**
@@ -225,7 +229,11 @@ class SupplierPresenter extends Presenter
*/
public function viewUrl()
{
- return route('suppliers.show', $this->id);
+ if (auth()->user()->can('view', ['\App\Models\Supplier', $this])) {
+ return (string)link_to_route('suppliers.show', $this->display_name, $this->id);
+ } else {
+ return e($this->display_name);
+ }
}
public function glyph()
@@ -241,9 +249,9 @@ class SupplierPresenter extends Presenter
public function formattedNameLink() {
if (auth()->user()->can('view', ['\App\Models\Supplier', $this])) {
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('suppliers.show', e($this->id)).'">'.e($this->name).'</a>';
+ return ($this->tag_color ? "<i class='fa-solid fa-square fa-fw' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').'<a href="'.route('suppliers.show', e($this->id)).'">'.e($this->name).'</a>';
}
- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
+ return ($this->tag_color ? "<i class='fa-solid fa-square fa-fw' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').e($this->name);
}
}
diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php
index 6316fc0ba8..2b234c3f7d 100644
--- a/app/Presenters/UserPresenter.php
+++ b/app/Presenters/UserPresenter.php
@@ -526,7 +526,12 @@ class UserPresenter extends Presenter
*/
public function nameUrl()
{
- return (string) link_to_route('users.show', $this->display_name, $this->id);
+ if (auth()->user()->can('view', ['\App\Models\User', $this])) {
+ return (string)link_to_route('users.show', $this->display_name, $this->id);
+ } else {
+ return e($this->display_name);
+ }
+
}
/**
@@ -542,4 +547,13 @@ class UserPresenter extends Presenter
{
return '<x-icon type="user"/>';
}
+
+ public function formattedNameLink() {
+
+ if (auth()->user()->can('view', ['\App\Models\User', $this])) {
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('users.show', e($this->id)).'">'.e($this->display_name).'</a>';
+ }
+
+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').e($this->display_name);
+ }
}