setupShowOperation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 22
rs 9.8333
cc 1
nc 1
nop 0
1
<?php
2
3
namespace MedianetDev\BackpackForm\Http\Controllers\Admin;
4
5
use Illuminate\Support\Facades\Route;
6
use Backpack\CRUD\app\Http\Controllers\CrudController;
7
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
8
use MedianetDev\BackpackForm\Http\Requests\FormbuilderEntryRequest;
9
10
/**
11
 * Class FormbuilderentryCrudController
12
 * @package App\Http\Controllers\Admin
13
 * @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
14
 */
15
class FormbuilderEntryCrudController extends CrudController
16
{
17
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
0 ignored issues
show
Bug introduced by
The trait Backpack\CRUD\app\Http\C...perations\ListOperation requires the property $entity_name_plural which is not provided by MedianetDev\BackpackForm...lderEntryCrudController.
Loading history...
18
    // use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
19
    // use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
20
    use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
21
    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
0 ignored issues
show
introduced by
The trait Backpack\CRUD\app\Http\C...perations\ShowOperation requires some properties which are not provided by MedianetDev\BackpackForm...lderEntryCrudController: $model, $entity_name, $route
Loading history...
22
23
    /**
24
     * Configure the CrudPanel object. Apply settings to all operations.
25
     *
26
     * @return void
27
     */
28
    public function setup()
29
    {
30
        CRUD::setModel(\MedianetDev\BackpackForm\Models\FormbuilderEntry::class);
31
        CRUD::setEntityNameStrings(__('medianet-dev.backpack-form::formbuilder.labels.entity_entry'), __('medianet-dev.backpack-form::formbuilder.labels.entities_entry'));
0 ignored issues
show
Bug introduced by
It seems like __('medianet-dev.backpac...labels.entities_entry') can also be of type array and array; however, parameter $plural of Backpack\CRUD\app\Librar...:setEntityNameStrings() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

31
        CRUD::setEntityNameStrings(__('medianet-dev.backpack-form::formbuilder.labels.entity_entry'), /** @scrutinizer ignore-type */ __('medianet-dev.backpack-form::formbuilder.labels.entities_entry'));
Loading history...
Bug introduced by
It seems like __('medianet-dev.backpac...r.labels.entity_entry') can also be of type array and array; however, parameter $singular of Backpack\CRUD\app\Librar...:setEntityNameStrings() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

31
        CRUD::setEntityNameStrings(/** @scrutinizer ignore-type */ __('medianet-dev.backpack-form::formbuilder.labels.entity_entry'), __('medianet-dev.backpack-form::formbuilder.labels.entities_entry'));
Loading history...
32
        $id_form = Route::current()->parameter('id_form');
33
        if ($id_form) {
34
            $this->crud->addClause('where', 'fb_form_id', '=', $id_form);
35
            CRUD::setRoute(config('backpack.base.route_prefix') . '/formbuilder/' . $id_form . '/formbuilderentry');
0 ignored issues
show
Bug introduced by
Are you sure $id_form of type object|string can be used in concatenation? ( Ignorable by Annotation )

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

35
            CRUD::setRoute(config('backpack.base.route_prefix') . '/formbuilder/' . /** @scrutinizer ignore-type */ $id_form . '/formbuilderentry');
Loading history...
36
        } else {
37
            CRUD::setRoute(config('backpack.base.route_prefix') . '/formbuilderentry');
38
        }
39
    }
40
41
    /**
42
     * Define what happens when the List operation is loaded.
43
     *
44
     * @see  https://backpackforlaravel.com/docs/crud-operation-list-entries
45
     * @return void
46
     */
47
    protected function setupListOperation()
48
    {
49
        $this->crud->addColumns([
50
            [
51
                'name' => 'formbuilder.title',
52
                'label' => ucfirst(__('medianet-dev.backpack-form::formbuilder.labels.entity_form')),
0 ignored issues
show
Bug introduced by
It seems like __('medianet-dev.backpac...er.labels.entity_form') can also be of type array and array; however, parameter $string of ucfirst() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

52
                'label' => ucfirst(/** @scrutinizer ignore-type */ __('medianet-dev.backpack-form::formbuilder.labels.entity_form')),
Loading history...
53
                'type' => 'text'
54
            ],
55
            [
56
                'name' => 'created_at',
57
                'type' => 'datetime',
58
                'label' => ucfirst(__('medianet-dev.backpack-form::formbuilder.labels.created_at'))
59
            ]
60
        ]);
61
    }
62
63
    /**
64
     * Define what happens when the Update operation is loaded.
65
     *
66
     * @see https://backpackforlaravel.com/docs/crud-operation-update
67
     * @return void
68
     */
69
    protected function setupShowOperation()
70
    {
71
        $this->crud->addColumns([
72
            [
73
                'name' => 'formbuilder.title',
74
                'label' => ucfirst(__('medianet-dev.backpack-form::formbuilder.labels.entity_form')),
0 ignored issues
show
Bug introduced by
It seems like __('medianet-dev.backpac...er.labels.entity_form') can also be of type array and array; however, parameter $string of ucfirst() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

74
                'label' => ucfirst(/** @scrutinizer ignore-type */ __('medianet-dev.backpack-form::formbuilder.labels.entity_form')),
Loading history...
75
                'type' => 'text'
76
            ],
77
            [
78
                'name' => 'created_at',
79
                'type' => 'datetime',
80
                'label' => ucfirst(__('medianet-dev.backpack-form::formbuilder.labels.created_at'))
81
            ],
82
            [
83
                'name' => 'structure_result',
84
                'type' => 'view',
85
                'label' => ucfirst(__('medianet-dev.backpack-form::formbuilder.labels.form')),
86
                'view' => 'medianet.backpack-form::columns.form_builder_entry',
87
            ]
88
        ]);
89
        $this->crud->removeColumn('structure_form');
90
        $this->crud->removeColumn('fb_form_id');
91
    }
92
}
93