Issues (2963)

Http/Controllers/Select/MuninPluginController.php (3 issues)

1
<?php
2
/**
3
 * MuninPluginController.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\MuninPlugin;
29
30
class MuninPluginController 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 MuninPlugin::hasAccess($request->user())
41
            ->with(['device' => function ($query) {
42
                $query->select('device_id', 'hostname', 'sysName');
43
            }])
44
            ->select('mplug_id', 'mplug_type', 'device_id');
45
    }
46
47
    /**
48
     * @param  MuninPlugin  $munin_plugin
49
     */
50
    public function formatItem($munin_plugin)
51
    {
52
        return [
53
            'id' => $munin_plugin->mplug_id,
54
            'text' => $munin_plugin->device->shortDisplayName() . ' - ' . $munin_plugin->mplug_type,
0 ignored issues
show
Bug Best Practice introduced by
The property mplug_type does not exist on App\Models\MuninPlugin. Since you implemented __get, consider adding a @property annotation.
Loading history...
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 ignore-call  annotation

54
            'text' => $munin_plugin->device->/** @scrutinizer ignore-call */ shortDisplayName() . ' - ' . $munin_plugin->mplug_type,

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...
Bug Best Practice introduced by
The property device does not exist on App\Models\MuninPlugin. Since you implemented __get, consider adding a @property annotation.
Loading history...
55
        ];
56
    }
57
}
58