|
1
|
|
|
<?php |
|
2
|
|
|
namespace Serverfireteam\Panel; |
|
3
|
|
|
|
|
4
|
|
|
use Illuminate\Routing\Controller; |
|
5
|
|
|
/* |
|
6
|
|
|
* To change this license header, choose License Headers in Project Properties. |
|
7
|
|
|
* To change this template file, choose Tools | Templates |
|
8
|
|
|
* and open the template in the editor. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
class UsersController extends Controller{ |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
public function all($entity){ |
|
15
|
|
|
|
|
16
|
|
|
parent::all($entity); |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
$this->filter = \DataFilter::source(new \User()); |
|
|
|
|
|
|
19
|
|
|
$this->filter->add('id', 'ID', 'text'); |
|
20
|
|
|
$this->filter->add('name', 'Name', 'text'); |
|
21
|
|
|
$this->filter->submit('search'); |
|
22
|
|
|
$this->filter->reset('reset'); |
|
23
|
|
|
$this->filter->build(); |
|
24
|
|
|
|
|
25
|
|
|
$this->grid = \DataGrid::source($this->filter); |
|
|
|
|
|
|
26
|
|
|
$this->grid->add('id','ID', true)->style("width:100px"); |
|
27
|
|
|
$this->grid->add('name','Name'); |
|
28
|
|
|
$this->addStylesToGrid(); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
return $this->returnView(); |
|
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
public function edit($entity){ |
|
37
|
|
|
|
|
38
|
|
|
parent::edit($entity); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
$this->edit = \DataEdit::source(new \User()); |
|
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
$this->edit->label('Edit User'); |
|
43
|
|
|
$this->edit->link("rapyd-demo/filter","Articles", "TR")->back(); |
|
44
|
|
|
$this->edit->add('name','Name', 'text')->rule('required|min:5'); |
|
45
|
|
|
$this->edit->add('username','userame', 'text')->rule('required|min:5'); |
|
46
|
|
|
return $this->returnEditView(); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getCreateUser(){ |
|
50
|
|
|
return \View::make('panelViews::createUser'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function postCreateUser(){ |
|
54
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
} |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: