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; |
|
|
|
|
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; |
|
|
|
|
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')); |
|
|
|
|
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'); |
|
|
|
|
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')), |
|
|
|
|
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')), |
|
|
|
|
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
|
|
|
|