1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Admin\User; |
||
4 | |||
5 | |||
6 | use Apps\ActiveRecord\User; |
||
7 | use Ffcms\Core\Arch\View; |
||
8 | use Ffcms\Core\Exception\NotFoundException; |
||
9 | use Ffcms\Core\Network\Request; |
||
10 | use Ffcms\Core\Network\Response; |
||
11 | |||
12 | /** |
||
13 | * Trait ActionApprove |
||
14 | * @package Apps\Controller\Admin\User |
||
15 | * @property Request $request |
||
16 | * @property Response $response |
||
17 | * @property View $view |
||
18 | */ |
||
19 | trait ActionApprove |
||
20 | { |
||
21 | /** |
||
22 | * Approve user and redirect to user list |
||
23 | * @param string $id |
||
24 | * @return void |
||
25 | * @throws NotFoundException |
||
26 | */ |
||
27 | public function approve($id) |
||
28 | { |
||
29 | /** @var User $record */ |
||
30 | $record = User::where('id', $id) |
||
31 | ->whereNotNull('approve_token') |
||
32 | ->first(); |
||
33 | |||
34 | if (!$record) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
35 | throw new NotFoundException(__('User not found')); |
||
36 | } |
||
37 | |||
38 | $record->approve_token = null; |
||
39 | $record->save(); |
||
40 | $this->response->redirect('user/index'); |
||
41 | } |
||
42 | } |