1 | <?php |
||||
2 | /** |
||||
3 | * ServiceController.php |
||||
4 | * |
||||
5 | * -Description- |
||||
6 | * |
||||
7 | * This program is free software: you can redistribute it and/or modify |
||||
8 | * it under the terms of the GNU General Public License as published by |
||||
9 | * the Free Software Foundation, either version 3 of the License, or |
||||
10 | * (at your option) any later version. |
||||
11 | * |
||||
12 | * This program is distributed in the hope that it will be useful, |
||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||||
15 | * GNU General Public License for more details. |
||||
16 | * |
||||
17 | * You should have received a copy of the GNU General Public License |
||||
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
19 | * |
||||
20 | * @link https://www.librenms.org |
||||
21 | * |
||||
22 | * @copyright 2018 Tony Murray |
||||
23 | * @author Tony Murray <[email protected]> |
||||
24 | */ |
||||
25 | |||||
26 | namespace App\Http\Controllers\Select; |
||||
27 | |||||
28 | use App\Models\Service; |
||||
29 | |||||
30 | class ServiceController extends SelectController |
||||
31 | { |
||||
32 | /** |
||||
33 | * Defines the base query for this resource |
||||
34 | * |
||||
35 | * @param \Illuminate\Http\Request $request |
||||
36 | * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder |
||||
37 | */ |
||||
38 | protected function baseQuery($request) |
||||
39 | { |
||||
40 | return Service::hasAccess($request->user()) |
||||
41 | ->with(['device' => function ($query) { |
||||
42 | $query->select('device_id', 'hostname', 'sysName'); |
||||
43 | }]) |
||||
44 | ->select('service_id', 'service_type', 'service_desc', 'device_id'); |
||||
45 | } |
||||
46 | |||||
47 | /** |
||||
48 | * @param Service $service |
||||
49 | */ |
||||
50 | public function formatItem($service) |
||||
51 | { |
||||
52 | return [ |
||||
53 | 'id' => $service->service_id, |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
54 | 'text' => $service->device->shortDisplayName() . ' - ' . $service->service_type . ' (' . $service->service_desc . ')', |
||||
0 ignored issues
–
show
The method
shortDisplayName() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
The property
service_desc does not exist on App\Models\Service . Since you implemented __get , consider adding a @property annotation.
Loading history...
The property
service_type does not exist on App\Models\Service . Since you implemented __get , consider adding a @property annotation.
Loading history...
The property
device does not exist on App\Models\Service . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
55 | ]; |
||||
56 | } |
||||
57 | } |
||||
58 |