public function postCreate() { $a = new Admin(); $a->fill($_POST); $a->password = password_hash($_POST['password'], PASSWORD_DEFAULT); $result = $a->save(); if ($result) { $this->service->flash('The admin was created.', 'success'); } else { $this->service->flash('Can\'t create the admin.', 'alert'); } return $this->service->back(); }
public function getByEmail($email) { $pdo = Config::getInstance()->get('db.pdo'); $stmt = $pdo->prepare('SELECT * FROM admins WHERE email = :email LIMIT 1'); $result = $stmt->execute(['email' => $email]); if ($result) { $admin = $stmt->fetch(); $a = new Admin(); $a->fill($admin); return $a; } return null; }