List ungrouped devices on group management page (#10527)

* list ungrouped devices on group management page

* some code changes

* some code changes

* change query to eager loading

* use url macro

* Update resources/views/device-group/index.blade.php

Co-Authored-By: Neil Lathwood <gh+n@laf.io>

* Title Case

* style fixes

* inline @if

* remove container

* revert force push
This commit is contained in:
SourceDoctor
2019-09-21 07:25:02 +02:00
committed by Tony Murray
parent d8eb3ab90e
commit b606a42ba9
2 changed files with 37 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Device;
use App\Models\DeviceGroup;
use Illuminate\Validation\Rule;
use Illuminate\Http\Request;
@@ -25,8 +26,13 @@ class DeviceGroupController extends Controller
{
$this->authorize('manage', DeviceGroup::class);
$ungrouped_devices = Device::orderBy('hostname')->whereNotIn('device_id', function ($query) {
$query->select('device_id')->from('device_group_device');
})->get();
return view('device-group.index', [
'device_groups' => DeviceGroup::orderBy('name')->withCount('devices')->get(),
'ungrouped_devices' => $ungrouped_devices,
]);
}