Skip to content

Commit 590f77b

Browse files
committed
Updated controllers and presenters
1 parent 09575e5 commit 590f77b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+326
-54
lines changed

app/Http/Controllers/Api/CategoriesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function index(Request $request) : array
4343
'created_at',
4444
'updated_at',
4545
'image',
46+
'tag_color',
4647
'notes',
4748
];
4849

@@ -57,6 +58,7 @@ public function index(Request $request) : array
5758
'require_acceptance',
5859
'checkin_email',
5960
'image',
61+
'tag_color',
6062
'notes',
6163
])
6264
->with('adminuser')

app/Http/Controllers/Api/DepartmentsController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DepartmentsController extends Controller
2424
public function index(Request $request) : JsonResponse | array
2525
{
2626
$this->authorize('view', Department::class);
27-
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes'];
27+
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes', 'tag_color'];
2828

2929
$departments = Department::select(
3030
[
@@ -38,6 +38,7 @@ public function index(Request $request) : JsonResponse | array
3838
'departments.created_at',
3939
'departments.updated_at',
4040
'departments.image',
41+
'departments.tag_color',
4142
'departments.notes'
4243
])->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count');
4344

@@ -61,6 +62,10 @@ public function index(Request $request) : JsonResponse | array
6162
$departments->where('location_id', '=', $request->input('location_id'));
6263
}
6364

65+
if ($request->filled('tag_color')) {
66+
$departments->where('tag_color', '=', $request->input('departments.tag_color'));
67+
}
68+
6469
// Make sure the offset and limit are actually integers and do not exceed system limits
6570
$offset = ($request->input('offset') > $departments->count()) ? $departments->count() : app('api_offset_value');
6671
$limit = app('api_limit_value');

app/Http/Controllers/Api/LocationsController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function index(Request $request) : JsonResponse | array
5959
'state',
6060
'updated_at',
6161
'zip',
62+
'tag_color',
6263
'notes',
6364
];
6465

@@ -81,6 +82,8 @@ public function index(Request $request) : JsonResponse | array
8182
'locations.ldap_ou',
8283
'locations.currency',
8384
'locations.company_id',
85+
'locations.tag_color',
86+
'locations.tag_color',
8487
'locations.notes',
8588
'locations.created_by',
8689
'locations.deleted_at',
@@ -145,6 +148,10 @@ public function index(Request $request) : JsonResponse | array
145148
$locations->onlyTrashed();
146149
}
147150

151+
if ($request->filled('tag_color')) {
152+
$locations->where('tag_color', '=', $request->input('locations.tag_color'));
153+
}
154+
148155
// Make sure the offset and limit are actually integers and do not exceed system limits
149156
$offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value');
150157
$limit = app('api_limit_value');

app/Http/Controllers/Api/ManufacturersController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function index(Request $request) : JsonResponse | array
4747
'consumables_count',
4848
'components_count',
4949
'licenses_count',
50+
'tag_color',
5051
'notes',
5152
];
5253

@@ -63,6 +64,7 @@ public function index(Request $request) : JsonResponse | array
6364
'updated_at',
6465
'image',
6566
'deleted_at',
67+
'tag_color',
6668
'notes',
6769
])
6870
->with('adminuser')
@@ -104,6 +106,10 @@ public function index(Request $request) : JsonResponse | array
104106
$manufacturers->where('support_email', '=', $request->input('support_email'));
105107
}
106108

109+
if ($request->filled('tag_color')) {
110+
$manufacturers->where('tag_color', '=', $request->input('manufacturers.tag_color'));
111+
}
112+
107113
// Make sure the offset and limit are actually integers and do not exceed system limits
108114
$offset = ($request->input('offset') > $manufacturers->count()) ? $manufacturers->count() : app('api_offset_value');
109115
$limit = app('api_limit_value');

app/Http/Controllers/Api/SuppliersController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ public function index(Request $request): array
5050
'accessories_count',
5151
'components_count',
5252
'consumables_count',
53+
'tag_color',
5354
'url',
5455
'notes',
5556
];
5657

5758
$suppliers = Supplier::select(
58-
['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip'])
59+
['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip', 'tag_color'])
5960
->withCount('assets as assets_count')
6061
->withCount('licenses as licenses_count')
6162
->withCount('accessories as accessories_count')

app/Http/Controllers/CategoriesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
7878
$category->require_acceptance = $request->input('require_acceptance', '0');
7979
$category->alert_on_response = $request->input('alert_on_response', '0');
8080
$category->checkin_email = $request->input('checkin_email', '0');
81+
$category->tag_color = $request->input('tag_color');
8182
$category->notes = $request->input('notes');
8283
$category->created_by = auth()->id();
8384

@@ -132,6 +133,7 @@ public function update(ImageUploadRequest $request, Category $category) : Redire
132133
$category->require_acceptance = $request->input('require_acceptance', '0');
133134
$category->alert_on_response = $request->input('alert_on_response', '0');
134135
$category->checkin_email = $request->input('checkin_email', '0');
136+
$category->tag_color = $request->input('tag_color');
135137
$category->notes = $request->input('notes');
136138

137139
$category = $request->handleImages($category);

app/Http/Controllers/DepartmentsController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
5555
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
5656
$department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null);
5757
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
58+
$department->tag_color = $request->input('tag_color');
5859
$department->notes = $request->input('notes');
5960
$department = $request->handleImages($department);
6061

@@ -157,6 +158,7 @@ public function update(ImageUploadRequest $request, Department $department) : Re
157158
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
158159
$department->phone = $request->input('phone');
159160
$department->fax = $request->input('fax');
161+
$department->tag_color = $request->input('tag_color');
160162
$department->notes = $request->input('notes');
161163
$department = $request->handleImages($department);
162164

app/Http/Controllers/LocationsController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
8282
$location->created_by = auth()->id();
8383
$location->phone = request('phone');
8484
$location->fax = request('fax');
85+
$location->tag_color = $request->input('tag_color');
8586
$location->notes = $request->input('notes');
8687
$location->company_id = Company::getIdForCurrentUser($request->input('company_id'));
8788

@@ -156,6 +157,7 @@ public function update(ImageUploadRequest $request, Location $location) : Redire
156157
$location->fax = request('fax');
157158
$location->ldap_ou = $request->input('ldap_ou');
158159
$location->manager_id = $request->input('manager_id');
160+
$location->tag_color = $request->input('tag_color');
159161
$location->notes = $request->input('notes');
160162

161163
// Only scope the location if the setting is enabled

app/Http/Controllers/ManufacturersController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
101101
$manufacturer->support_email = $request->input('support_email');
102102
$manufacturer->notes = $request->input('notes');
103103
$manufacturer = $request->handleImages($manufacturer);
104+
$manufacturer->tag_color = $request->input('tag_color');
104105

105106
if ($manufacturer->save()) {
106107
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.create.success'));
@@ -142,6 +143,7 @@ public function update(ImageUploadRequest $request, Manufacturer $manufacturer)
142143
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
143144
$manufacturer->support_phone = $request->input('support_phone');
144145
$manufacturer->support_email = $request->input('support_email');
146+
$manufacturer->tag_color = $request->input('tag_color');
145147
$manufacturer->notes = $request->input('notes');
146148

147149
// Set the model's image property to null if the image is being deleted

app/Http/Controllers/SuppliersController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
6767
$supplier->phone = request('phone');
6868
$supplier->fax = request('fax');
6969
$supplier->email = request('email');
70+
$supplier->tag_color = $request->input('tag_color');
7071
$supplier->notes = request('notes');
7172
$supplier->url = $supplier->addhttp(request('url'));
7273
$supplier->created_by = auth()->id();
@@ -111,6 +112,7 @@ public function update(ImageUploadRequest $request, Supplier $supplier) : Redire
111112
$supplier->fax = request('fax');
112113
$supplier->email = request('email');
113114
$supplier->url = $supplier->addhttp(request('url'));
115+
$supplier->tag_color = $request->input('tag_color');
114116
$supplier->notes = request('notes');
115117
$supplier = $request->handleImages($supplier);
116118

0 commit comments

Comments
 (0)