Котнтроллер Users php public function startAction if Users findFirstBy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Котнтроллер Users:
<?php
public function startAction() {
if(!Users::findFirstByIp($this->request->getClientAddress())){
$start = new Users();
$login = 'Воитель'.(count($start::find()) + 1);
$start->login = $login;
$start->ip = $this->request->getClientAddress();
$start->updated_at = (string) \Сontrario\Carbon::now();
$start->created_at = (string) \Сontrario\Carbon::now();
$start->password = $this->security->hash('temp');
if ($start->save()) {
if ($this->auth->attempt(array('login' => $login, 'password' => 'temp'))) {
$start = $this->auth->user();
$this->flash->success('Регистрация прошла успешно. Добро пожаловать, '.$start->login);
$this->response->redirect();
$this->view->disable();
}
}
}
else {
$this->response->redirect();
$this->view->disable();
}
}