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

Passed
Push — add-form-component ( 5acaa0...b390e4 )
by Pedro
17:27 queued 02:07
created

CreateOperation::createForm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 17
rs 9.9332
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Operations;
4
5
use Backpack\CRUD\app\Library\CrudPanel\Hooks\Facades\LifecycleHook;
6
use Illuminate\Support\Facades\Route;
7
8
trait CreateOperation
9
{
10
    /**
11
     * Define which routes are needed for this operation.
12
     *
13
     * @param  string  $segment  Name of the current entity (singular). Used as first URL segment.
14
     * @param  string  $routeName  Prefix of the route name.
15
     * @param  string  $controller  Name of the current CrudController.
16
     */
17
    protected function setupCreateRoutes($segment, $routeName, $controller)
18
    {
19
        Route::get($segment.'/create', [
20
            'as' => $routeName.'.create',
21
            'uses' => $controller.'@create',
22
            'operation' => 'create',
23
        ]);
24
25
        Route::post($segment, [
26
            'as' => $routeName.'.store',
27
            'uses' => $controller.'@store',
28
            'operation' => 'create',
29
        ]);
30
    }
31
32
    /**
33
     * Add the default settings, buttons, etc that this operation needs.
34
     */
35
    protected function setupCreateDefaults()
36
    {
37
        $this->crud->allowAccess('create');
38
39
        LifecycleHook::hookInto('create:before_setup', function () {
0 ignored issues
show
Bug introduced by
The method hookInto() does not exist on Backpack\CRUD\app\Librar...s\Facades\LifecycleHook. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        LifecycleHook::/** @scrutinizer ignore-call */ 
40
                       hookInto('create:before_setup', function () {
Loading history...
40
            $this->crud->setupDefaultSaveActions();
41
        });
42
43
        LifecycleHook::hookInto('list:before_setup', function () {
44
            $this->crud->addButton('top', 'create', 'view', 'crud::buttons.create');
45
        });
46
    }
47
48
    /**
49
     * Show the form for creating inserting a new row.
50
     *
51
     * @return \Illuminate\Contracts\View\View
52
     */
53
    public function create()
54
    {
55
        $this->crud->hasAccessOrFail('create');
56
57
        // prepare the fields you need to show
58
        $this->data['crud'] = $this->crud;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
59
        $this->data['saveAction'] = $this->crud->getSaveAction();
60
        $this->data['title'] = $this->crud->getTitle() ?? trans('backpack::crud.add').' '.$this->crud->entity_name;
61
62
        // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
63
        return  request()->ajax() ?
64
            view('crud::components.form.ajax_response', $this->data) :
65
            view($this->crud->getCreateView(), $this->data);
66
    }
67
68
    /**
69
     * Store a newly created resource in the database.
70
     *
71
     * @return \Illuminate\Http\RedirectResponse
72
     */
73
    public function store()
74
    {
75
        $this->crud->hasAccessOrFail('create');
76
77
        // execute the FormRequest authorization and validation, if one is required
78
        $request = $this->crud->validateRequest();
79
80
        // register any Model Events defined on fields
81
        $this->crud->registerFieldEvents();
82
83
        // insert item in the db
84
        $item = $this->crud->create($this->crud->getStrippedSaveRequest($request));
85
        $this->data['entry'] = $this->crud->entry = $item;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
86
87
        // show a success message
88
        \Alert::success(trans('backpack::crud.insert_success'))->flash();
0 ignored issues
show
Bug introduced by
The type Alert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
89
90
        // save the redirect choice for next time
91
        $this->crud->setSaveAction();
92
93
        return $this->crud->performSaveAction($item->getKey());
94
    }
95
}
96