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

Test Setup Failed
Pull Request — master (#4294)
by Martin Selim
10:32
created

ForceDeleteRestoreOperation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A restore() 0 5 1
A forceDelete() 0 5 1
A setupForceDeleteRestoreRoutes() 0 12 1
A setupForceDeleteDefaults() 0 12 1
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Operations;
4
5
use Illuminate\Support\Facades\Route;
6
7
trait ForceDeleteRestoreOperation
8
{
9
    /**
10
     * Define which routes are needed for this operation.
11
     *
12
     * @param string $segment    Name of the current entity (singular). Used as first URL segment.
13
     * @param string $routeName  Prefix of the route name.
14
     * @param string $controller Name of the current CrudController.
15
     */
16
    protected function setupForceDeleteRestoreRoutes($segment, $routeName, $controller)
17
    {
18
        Route::delete($segment.'/{id}/forceDelete', [
19
            'as'        => $routeName.'.forceDelete',
20
            'uses'      => $controller.'@forceDelete',
21
            'operation' => 'forceDelete',
22
        ]);
23
24
        Route::post($segment.'/{id}/restore', [
25
            'as'        => $routeName.'.restore',
26
            'uses'      => $controller.'@restore',
27
            'operation' => 'restore',
28
        ]);
29
    }
30
31
    /**
32
     * Add the default settings, buttons, etc that this operation needs.
33
     */
34
    protected function setupForceDeleteDefaults()
35
    {
36
        $this->crud->allowAccess('forceDelete');
37
        $this->crud->allowAccess('restore');
38
39
        $this->crud->operation('forceDelete', function () {
40
            $this->crud->loadDefaultOperationSettingsFromConfig();
41
        });
42
43
        $this->crud->operation('list', function () {
44
            $this->crud->addButton('line', 'restore', 'view', 'crud::buttons.restore', 'end');
45
            $this->crud->addButton('line', 'force-delete', 'view', 'crud::buttons.force-delete', 'end');
46
47
        });
48
    }
49
50
    /**
51
     * @param $id
52
     * @return mixed
53
     */
54
    public function forceDelete($id)
55
    {
56
        $this->crud->hasAccessOrFail('forceDelete');
57
58
        return $this->crud->model->withTrashed()->find($id)->forceDelete();
59
60
    }
61
62
63
    /**
64
     * @param $id
65
     * @return mixed
66
     */
67
    public function restore($id)
68
    {
69
        $this->crud->hasAccessOrFail('restore');
70
71
        return $this->crud->model->withTrashed()->find($id)->restore();
72
73
    }
74
}
75