|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Serverfireteam\Panel; |
|
4
|
|
|
/* |
|
5
|
|
|
* To change this license header, choose License Headers in Project Properties. |
|
6
|
|
|
* To change this template file, choose Tools | Templates |
|
7
|
|
|
* and open the template in the editor. |
|
8
|
|
|
*/ |
|
9
|
|
|
use Serverfireteam\Panel\CrudController; |
|
10
|
|
|
use \Illuminate\Http\Request; |
|
11
|
|
|
/** |
|
12
|
|
|
* Description of PagePanel |
|
13
|
|
|
* |
|
14
|
|
|
* @author alireza |
|
15
|
|
|
*/ |
|
16
|
|
|
class AdminController extends CrudController{ |
|
17
|
|
|
|
|
18
|
|
|
public function all($entity){ |
|
19
|
|
|
parent::all($entity); |
|
20
|
|
|
|
|
21
|
|
|
$this->filter = \DataFilter::source(Admin::with('roles')); |
|
22
|
|
|
$this->filter->add('id', 'ID', 'text'); |
|
23
|
|
|
$this->filter->add('first_name', 'First name', 'text'); |
|
24
|
|
|
$this->filter->add('last_name', 'Last Name', 'text'); |
|
25
|
|
|
$this->filter->add('email', 'Email', 'text'); |
|
26
|
|
|
$this->filter->submit('search'); |
|
27
|
|
|
$this->filter->reset('reset'); |
|
28
|
|
|
$this->filter->build(); |
|
29
|
|
|
|
|
30
|
|
|
$this->grid = \DataGrid::source($this->filter); |
|
31
|
|
|
$this->grid->add('id','ID', true)->style("width:100px"); |
|
32
|
|
|
$this->grid->add('{{ $first_name }} {{ $last_name}}','first name'); |
|
33
|
|
|
$this->grid->add('email','Email'); |
|
34
|
|
|
$this->grid->add('{{ implode(", ", $roles->pluck("name")->all()) }}', 'Role'); |
|
35
|
|
|
|
|
36
|
|
|
$this->addStylesToGrid(); |
|
37
|
|
|
return $this->returnView(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function edit($entity){ |
|
41
|
|
|
|
|
42
|
|
|
if (\Request::input('password') != null ) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
$new_input = array('password' => \Hash::make(\Request::input('password'))); |
|
45
|
|
|
\Request::merge($new_input); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
parent::edit($entity); |
|
49
|
|
|
|
|
50
|
|
|
$this->edit = \DataEdit::source(new Admin()); |
|
51
|
|
|
|
|
52
|
|
|
$this->edit->label('Edit Admin'); |
|
53
|
|
|
$this->edit->link("rapyd-demo/filter","Articles", "TR")->back(); |
|
54
|
|
|
$this->edit->add('email','Email', 'text')->rule('required|min:5'); |
|
55
|
|
|
$this->edit->add('first_name', 'firstname', 'text'); |
|
56
|
|
|
$this->edit->add('last_name', 'lastname', 'text'); |
|
57
|
|
|
$this->edit->add('password', 'password', 'password')->rule('required'); |
|
58
|
|
|
$this->edit->add('roles','Roles','checkboxgroup')->options(Role::pluck('name', 'id')->all()); |
|
59
|
|
|
|
|
60
|
|
|
return $this->returnEditView(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|