Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 8c9cfb...1a8e53 )
by Cristian
10:22
created

SettingCrudController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 1
eloc 16
nc 1
nop 0
1
<?php namespace Backpack\Settings\app\Http\Controllers;
2
3
use Illuminate\Http\Request;
4
use App\Http\Requests;
5
use App\Http\Controllers\Controller;
6
use Backpack\CRUD\app\Http\Controllers\CrudController;
7
8
// VALIDATION
9
use Backpack\Settings\app\Http\Requests\SettingRequest as StoreRequest;
10
use Backpack\Settings\app\Http\Requests\SettingRequest as UpdateRequest;
11
12
class SettingCrudController extends CrudController {
13
14
	public function __construct() {
15
		parent::__construct();
16
17
        $this->crud->setModel("Backpack\Settings\app\Models\Setting");
0 ignored issues
show
Bug introduced by
The method setModel cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
18
        $this->crud->setEntityNameStrings('setting', 'settings');
0 ignored issues
show
Bug introduced by
The method setEntityNameStrings cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
19
        $this->crud->setRoute('admin/setting');
0 ignored issues
show
Bug introduced by
The method setRoute cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
20
        $this->crud->denyAccess(['create', 'delete']);
0 ignored issues
show
Bug introduced by
The method denyAccess cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
21
        $this->crud->setColumns(['name', 'value', 'description']);
0 ignored issues
show
Bug introduced by
The method setColumns cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
22
        $this->crud->addField([
0 ignored issues
show
Bug introduced by
The method addField cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
23
								'name' => 'name',
24
								'label' => 'Name',
25
								'type' => 'text',
26
								'disabled' => 'disabled'
27
							]);
28
        $this->crud->addField([
0 ignored issues
show
Bug introduced by
The method addField cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
29
								'name' => 'value',
30
								'label' => 'Value',
31
								'type' => 'text'
32
							]);
33
	}
34
35
	/**
36
	 * Display all rows in the database for this entity.
37
	 * This overwrites the default CrudController behaviour:
38
	 * - instead of showing all entries, only show the "active" ones
39
	 *
40
	 * @return Response
41
	 */
42
	public function index()
43
	{
44
		// if view_table_permission is false, abort
45
		$this->crud->hasAccessOrFail('list');
0 ignored issues
show
Bug introduced by
The method hasAccessOrFail cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
46
		$this->crud->addClause('where', 'active', 1); // <---- this is where it's different from CrudController::index()
0 ignored issues
show
Bug introduced by
The method addClause cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
47
48
		$this->data['entries'] = $this->crud->getEntries();
0 ignored issues
show
Bug introduced by
The method getEntries cannot be called on $this->crud (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
49
		$this->data['crud'] = $this->crud;
50
		$this->data['title'] = ucfirst($this->crud->entity_name_plural);
51
52
		// load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
53
		return view('crud::list', $this->data);
54
	}
55
56
	public function store(StoreRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
	{
58
		return parent::storeCrud();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (storeCrud() instead of store()). Are you sure this is correct? If so, you might want to change this to $this->storeCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
59
	}
60
61
	public function update(UpdateRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
	{
63
		return parent::updateCrud();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (updateCrud() instead of update()). Are you sure this is correct? If so, you might want to change this to $this->updateCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
64
	}
65
}
66