Skip to content

Commit b50765a

Browse files
committed
Added more to the views
1 parent 590f77b commit b50765a

File tree

18 files changed

+112
-35
lines changed

18 files changed

+112
-35
lines changed

app/Models/Department.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Http\Traits\UniqueUndeletedTrait;
66
use App\Models\Traits\CompanyableTrait;
77
use App\Models\Traits\Searchable;
8+
use App\Presenters\Presentable;
89
use Illuminate\Database\Eloquent\Factories\HasFactory;
910
use Watson\Validating\ValidatingTrait;
1011

@@ -22,7 +23,10 @@ class Department extends SnipeModel
2223
*/
2324
protected $injectUniqueIdentifier = true;
2425

25-
use ValidatingTrait, UniqueUndeletedTrait;
26+
protected $presenter = \App\Presenters\DepartmentPresenter::class;
27+
28+
29+
use ValidatingTrait, UniqueUndeletedTrait, Presentable;
2630

2731
protected $casts = [
2832
'manager_id' => 'integer',

app/Presenters/CategoryPresenter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ public function viewUrl()
154154
public function formattedNameLink() {
155155

156156
if (auth()->user()->can('category.view', $this)) {
157-
return ($this->tag_color ? "<i class='fa-solid fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('categories.show', e($this->id)).'">'.e($this->name).'</a>';
157+
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>';
158158
}
159159

160-
return ($this->tag_color ? "<i class='fa-solid fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
160+
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
161161
}
162162
}

app/Presenters/CompanyPresenter.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,13 @@ public function viewUrl()
175175
{
176176
return route('companies.show', $this->id);
177177
}
178+
179+
public function formattedNameLink() {
180+
181+
if (auth()->user()->can('company.view', $this)) {
182+
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>';
183+
}
184+
185+
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
186+
}
178187
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Presenters;
4+
5+
/**
6+
* Class DepartmentPresenter
7+
*/
8+
class DepartmentPresenter extends Presenter
9+
{
10+
11+
12+
public function formattedNameLink() {
13+
14+
if (auth()->user()->can('department.view', $this)) {
15+
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('departments.show', e($this->id)).'">'.e($this->name).'</a>';
16+
}
17+
18+
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
19+
}
20+
}

app/Presenters/LocationPresenter.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,13 @@ public function fullName()
375375
{
376376
return $this->name;
377377
}
378+
379+
public function formattedNameLink() {
380+
381+
if (auth()->user()->can('location.view', $this)) {
382+
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>';
383+
}
384+
385+
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
386+
}
378387
}

app/Presenters/ManufacturerPresenter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,14 @@ public function viewUrl()
191191
{
192192
return route('manufacturers.show', $this->id);
193193
}
194+
195+
public function formattedNameLink() {
196+
197+
if (auth()->user()->can('manufacturer.view', $this)) {
198+
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>';
199+
}
200+
201+
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
202+
}
203+
194204
}

app/Presenters/SupplierPresenter.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,13 @@ public function fullName()
237237
{
238238
return $this->name;
239239
}
240+
241+
public function formattedNameLink() {
242+
243+
if (auth()->user()->can('supplier.view', $this)) {
244+
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>';
245+
}
246+
247+
return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
248+
}
240249
}

public/css/build/app.css

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/build/app.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/build/overrides.css

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)