Passed
Push — main ( 030554...fba1e4 )
by Quentin
11:01 queued 04:37
created

SingletonModuleController::editSingleton()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 13
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace A17\Twill\Http\Controllers\Admin;
4
5
use Illuminate\Support\Facades\Session;
6
7
abstract class SingletonModuleController extends ModuleController
8
{
9
    protected $permalinkBase = '';
10
11
    public function index($parentModuleId = null)
12
    {
13
        throw new \Exception("{$this->getModelName()} has no index");
14
    }
15
16
    public function editSingleton()
17
    {
18
        $model = "App\\Models\\{$this->getModelName()}";
19
20
        $item = app($model)->first();
0 ignored issues
show
Bug introduced by
The method first() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        $item = app($model)->/** @scrutinizer ignore-call */ first();

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...
21
22
        if (!$item) {
23
            throw new \Exception("{$this->getModelName()} is missing");
24
        }
25
26
        Session::put('pages_back_link', url()->current());
27
28
        return view("admin.{$this->moduleName}.form", $this->form($item->id));
29
    }
30
}
31