Completed
Push — master ( 720025...0e57e6 )
by ARCANEDEV
04:07
created

PasswordResetsController::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Auth\Http\Controllers\Admin;
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\Admin
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', 'admin::auth.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
        $this->setTitle($title = 'List of password resets');
49
        $this->addBreadcrumb($title);
50
51
        return $this->view('admin.password-resets.list', compact('resets'));
52
    }
53
54
    public function delete()
55
    {
56
        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...
57
58
        $this->authorize(PasswordResetsPolicy::PERMISSION_DELETE);
59
60
        return response()->json([]);
61
    }
62
63
    public function clear()
64
    {
65
        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...
66
67
        $this->authorize(PasswordResetsPolicy::PERMISSION_DELETE);
68
69
        PasswordReset::getTokenRepository()->deleteExpired();
70
71
        return response()->json(['status' => 'success']);
72
    }
73
}
74