GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 489b8c...eb46e9 )
by Alireza
01:56
created

CrudController::finalizeFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace Serverfireteam\Panel;
3
4
use Illuminate\Routing\Controller;
5
6
class CrudController extends Controller
7
{
8
    const ID_COLUMN = 'id';
9
10
    public    $grid;
11
    public    $entity;
12
    public    $set;
13
    public    $edit;
14
    public    $filter;
15
    protected $lang;
16
    public    $helper_message;
17
18
    public function __construct(\Lang $lang)
19
    {
20
       // $this->entity = $params['entity'];
21
        $route = \App::make('route');
22
        $this->lang = $lang;
23
        $this->route = $route;
0 ignored issues
show
Bug introduced by
The property route does not seem to exist. Did you mean router?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
24
        $routeParamters = $route::current()->parameters();
25
        $this->setEntity($routeParamters['entity']);
26
    }
27
28
    /**
29
    * @param string $entity name of the entity
30
    */
31
    public function all($entity)
32
    {
33
        //$this->addStylesToGrid();
34
    }
35
36
    /**
37
    * @param string $entity name of the entity
38
    */
39
    public function edit($entity)
40
    {
41
42
    }
43
44
    public function getEntity() {
45
        return $this->entity;
46
    }
47
48
    public function setEntity($entity) {
49
        $this->entity = $entity;
50
    }
51
52
    public function getEntityModel() {
53
54
        $entity = $this->getEntity();
55
56
        $appHelper = new libs\AppHelper;
57
58
        if ( in_array($entity, Link::getMainUrls()) ) {
59
            $modelClass = 'Serverfireteam\\Panel\\'.$entity;
60
        } else {
61
            $modelClass = $appHelper->getNameSpace().$this->getEntity();
62
        }
63
64
        return new $modelClass;
65
    }
66
67
    public function addStylesToGrid($orderByColumn = self::ID_COLUMN, $paginateCount = 10)
68
    {
69
        $this->grid->edit('edit', trans('panel::fields.edit'), 'show|modify|delete');
70
71
72
        if ($orderByColumn === self::ID_COLUMN) {
73
            $orderByColumn = $this->getEntityModel()->getKeyName();
74
        }
75
76
        $this->grid->orderBy($orderByColumn, 'desc');
77
        $this->grid->paginate($paginateCount);
78
    }
79
80
    public function addHelperMessage($message)
81
    {
82
        $this->helper_message = $message;
83
    }
84
85
    public function returnView()
86
    {
87
        $configs = \Serverfireteam\Panel\Link::returnUrls();
88
89
        if (!isset($configs) || $configs == null) {
90
            throw new \Exception('NO URL is set yet !');
91
        } else if (!in_array($this->entity, $configs)) {
92
            throw new \Exception('This url is not set yet!');
93
        } else {
94
            return \View::make('panelViews::all', array(
95
             'grid' 	      => $this->grid,
96
             'filter' 	      => $this->filter,
97
             'title'          => $this->entity ,
98
	     'current_entity' => $this->entity,
99
	     'import_message' => (\Session::has('import_message')) ? \Session::get('import_message') : ''
100
            ));
101
        }
102
    }
103
104
    public function returnEditView()
105
    {
106
        $configs = \Serverfireteam\Panel\Link::returnUrls();
107
108
        if (!isset($configs) || $configs == null) {
109
            throw new \Exception('NO URL is set yet !');
110
        } else if (!in_array($this->entity, $configs)) {
111
            throw new \Exception('This url is not set yet !');
112
        } else {
113
           return \View::make('panelViews::edit', array('title'		 => $this->entity,
114
					                'edit' 		 => $this->edit,
115
							'helper_message' => $this->helper_message));
116
        }
117
    }
118
119
    public function finalizeFilter() {
120
        $lang = \App::make('lang');
0 ignored issues
show
Unused Code introduced by
$lang is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
121
        $this->filter->submit($this->lang->get('panel::fields.search'));
122
        $this->filter->reset($this->lang->get('panel::fields.reset'));
123
    }
124
}
125