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 ( 6bda91...26ffdc )
by Cristian
03:56 queued 24s
created

ListEntries   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 84
rs 10
c 0
b 0
f 0
wmc 10
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 10 1
B search() 0 37 8
A showDetailsRow() 0 13 1
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Operations;
4
5
trait ListEntries
6
{
7
    /**
8
     * Display all rows in the database for this entity.
9
     *
10
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
11
     */
12
    public function index()
13
    {
14
        $this->crud->hasAccessOrFail('list');
0 ignored issues
show
Bug introduced by
The property crud does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
16
        $this->data['crud'] = $this->crud;
0 ignored issues
show
Bug introduced by
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
        $this->data['title'] = ucfirst($this->crud->entity_name_plural);
18
19
        // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
20
        return view($this->crud->getListView(), $this->data);
21
    }
22
23
    /**
24
     * The search function that is called by the data table.
25
     *
26
     * @return  JSON Array of cells in HTML form.
27
     */
28
    public function search()
29
    {
30
        $this->crud->hasAccessOrFail('list');
31
32
        $totalRows = $filteredRows = $this->crud->count();
33
        $startIndex = $this->request->input('start') ?: 0;
0 ignored issues
show
Bug introduced by
The property request does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
        // if a search term was present
35
        if ($this->request->input('search') && $this->request->input('search')['value']) {
36
            // filter the results accordingly
37
            $this->crud->applySearchTerm($this->request->input('search')['value']);
38
            // recalculate the number of filtered rows
39
            $filteredRows = $this->crud->count();
40
        }
41
        // start the results according to the datatables pagination
42
        if ($this->request->input('start')) {
43
            $this->crud->skip($this->request->input('start'));
44
        }
45
        // limit the number of results according to the datatables pagination
46
        if ($this->request->input('length')) {
47
            $this->crud->take($this->request->input('length'));
48
        }
49
        // overwrite any order set in the setup() method with the datatables order
50
        if ($this->request->input('order')) {
51
            $column_number = $this->request->input('order')[0]['column'];
52
            $column_direction = $this->request->input('order')[0]['dir'];
53
            $column = $this->crud->findColumnById($column_number);
54
            if ($column['tableColumn']) {
55
                // clear any past orderBy rules
56
                $this->crud->query->getQuery()->orders = null;
57
                // apply the current orderBy rules
58
                $this->crud->orderBy($column['name'], $column_direction);
59
            }
60
        }
61
        $entries = $this->crud->getEntries();
62
63
        return $this->crud->getEntriesAsJsonForDatatables($entries, $totalRows, $filteredRows, $startIndex);
64
    }
65
66
    /**
67
     * Used with AJAX in the list view (datatables) to show extra information about that row that didn't fit in the table.
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
68
     * It defaults to showing some dummy text.
69
     *
70
     * It's enabled by:
71
     * - setting: $crud->details_row = true;
72
     * - adding the details route for the entity; ex: Route::get('page/{id}/details', 'PageCrudController@showDetailsRow');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 123 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
73
     * - adding a view with the following name to change what the row actually contains: app/resources/views/vendor/backpack/crud/details_row.blade.php
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 151 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
74
     */
75
    public function showDetailsRow($id)
76
    {
77
        $this->crud->hasAccessOrFail('details_row');
78
79
        // get entry ID from Request (makes sure its the last ID for nested resources)
80
        $id = $this->crud->getCurrentEntryId() ?? $id;
81
82
        $this->data['entry'] = $this->crud->getEntry($id);
83
        $this->data['crud'] = $this->crud;
84
85
        // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
86
        return view($this->crud->getDetailsRowView(), $this->data);
87
    }
88
}
89