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

Reorder::reorder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Operations;
4
5
trait Reorder
6
{
7
    /**
8
     *  Reorder the items in the database using the Nested Set pattern.
9
     *
10
     *  Database columns needed: id, parent_id, lft, rgt, depth, name/title
11
     *
12
     *  @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...
13
     */
14
    public function reorder()
15
    {
16
        $this->crud->hasAccessOrFail('reorder');
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...
17
18
        if (! $this->crud->isReorderEnabled()) {
19
            abort(403, 'Reorder is disabled.');
20
        }
21
22
        // get all results for that entity
23
        $this->data['entries'] = $this->crud->getEntries();
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...
24
        $this->data['crud'] = $this->crud;
25
        $this->data['title'] = trans('backpack::crud.reorder').' '.$this->crud->entity_name;
26
27
        // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
28
        return view($this->crud->getReorderView(), $this->data);
29
    }
30
31
    /**
32
     * Save the new order, using the Nested Set pattern.
33
     *
34
     * Database columns needed: id, parent_id, lft, rgt, depth, name/title
35
     *
36
     * @return
37
     */
38
    public function saveReorder()
39
    {
40
        $this->crud->hasAccessOrFail('reorder');
41
42
        $all_entries = \Request::input('tree');
43
44
        if (count($all_entries)) {
45
            $count = $this->crud->updateTreeOrder($all_entries);
46
        } else {
47
            return false;
48
        }
49
50
        return 'success for '.$count.' items';
51
    }
52
}
53