|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Serverfireteam\Panel; |
|
4
|
|
|
|
|
5
|
|
|
use Serverfireteam\Panel\CrudController; |
|
6
|
|
|
|
|
7
|
|
|
class PermissionController extends CrudController { |
|
8
|
|
|
|
|
9
|
|
View Code Duplication |
public function all($entity) { |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
parent::all($entity); |
|
12
|
|
|
|
|
13
|
|
|
$this->filter = \DataFilter::source(new Permission()); |
|
14
|
|
|
$this->filter->add('id', 'ID', 'text'); |
|
15
|
|
|
$this->filter->add('name', 'Name', 'text'); |
|
16
|
|
|
$this->filter->submit('search'); |
|
17
|
|
|
$this->filter->reset('reset'); |
|
18
|
|
|
$this->filter->build(); |
|
19
|
|
|
|
|
20
|
|
|
$this->grid = \DataGrid::source($this->filter); |
|
21
|
|
|
$this->grid->add('id', 'ID', true)->style("width:100px"); |
|
22
|
|
|
$this->grid->add('name', 'Url')->style('width:100px'); |
|
23
|
|
|
$this->grid->add('label', 'Description'); |
|
24
|
|
|
|
|
25
|
|
|
$this->addStylesToGrid(); |
|
26
|
|
|
|
|
27
|
|
|
return $this->returnView(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function edit($entity) { |
|
31
|
|
|
|
|
32
|
|
|
parent::edit($entity); |
|
33
|
|
|
|
|
34
|
|
|
$this->edit = \DataEdit::source(new Permission()); |
|
35
|
|
|
|
|
36
|
|
|
$helpMessage = (\Lang::get('panel::fields.roleHelp')); |
|
37
|
|
|
|
|
38
|
|
|
$this->edit->label('Edit Permission'); |
|
39
|
|
|
$this->edit->link("rapyd-demo/filter", "Articles", "TR")->back(); |
|
40
|
|
|
$this->edit->add('name', 'Url', 'text')->rule('required'); |
|
41
|
|
|
$this->edit->add('label', 'Description', 'text')->rule('required'); |
|
42
|
|
|
|
|
43
|
|
|
$this->edit->saved(function () use ($entity) { |
|
44
|
|
|
$this->edit->message('Awesome, Data Saved successfully'); |
|
45
|
|
|
$this->edit->link('panel/Permission/all', 'Back'); |
|
46
|
|
|
}); |
|
47
|
|
|
|
|
48
|
|
|
$this->addHelperMessage($helpMessage); |
|
49
|
|
|
|
|
50
|
|
|
return $this->returnEditView(); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.