Completed
Push — master ( 3c59f9...34cc61 )
by ARCANEDEV
03:16
created

PasswordResetsController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php namespace Arcanesoft\Auth\Http\Controllers\Foundation;
2
3
use Arcanesoft\Auth\Models\PasswordReset;
4
use Arcanesoft\Auth\Policies\PasswordResetsPolicy;
5
6
/**
7
 * Class     PasswordResetsController
8
 *
9
 * @package  Arcanesoft\Auth\Http\Controllers\Foundation
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class PasswordResetsController extends Controller
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /** @var int */
19
    protected $perPage = 30;
20
21
    /* ------------------------------------------------------------------------------------------------
22
     |  Constructor
23
     | ------------------------------------------------------------------------------------------------
24
     */
25
    /**
26
     * PasswordResetsController constructor.
27
     */
28
    public function __construct()
29
    {
30
        parent::__construct();
31
32
        $this->setCurrentPage('auth-password-resets');
33
        $this->addBreadcrumbRoute('Password Resets', 'auth::foundation.password-resets.index');
34
    }
35
36
    /* ------------------------------------------------------------------------------------------------
37
     |  Main Functions
38
     | ------------------------------------------------------------------------------------------------
39
     */
40
    public function index()
41
    {
42
        $this->authorize(PasswordResetsPolicy::PERMISSION_LIST);
43
44
        $resets = PasswordReset::with(['user'])
45
            ->orderBy('created_at', 'desc')
46
            ->paginate($this->perPage);
47
48
        $title = 'List of password resets';
49
        $this->setTitle($title);
50
        $this->addBreadcrumb($title);
51
52
        return $this->view('foundation.password-resets.list', compact('resets'));
53
    }
54
55
    public function delete()
56
    {
57
        parent::onlyAjax();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (onlyAjax() instead of delete()). Are you sure this is correct? If so, you might want to change this to $this->onlyAjax().

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...
58
59
        $this->authorize(PasswordResetsPolicy::PERMISSION_DELETE);
60
61
        return response()->json([]);
62
    }
63
64
    public function clear()
65
    {
66
        parent::onlyAjax();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (onlyAjax() instead of clear()). Are you sure this is correct? If so, you might want to change this to $this->onlyAjax().

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...
67
68
        $this->authorize(PasswordResetsPolicy::PERMISSION_DELETE);
69
70
        PasswordReset::getTokenRepository()->deleteExpired();
71
72
        return response()->json(['status' => 'success']);
73
    }
74
}
75