Guest User

Untitled

a guest
Mar 2nd, 2021
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2. namespace App\Model;
  3.  
  4. use Nette;
  5.  
  6. final class UserManager extends Nette\Application\UI\Presenter {
  7.     use Nette\SmartObject;
  8.  
  9.     private Nette\Database\Explorer $database;
  10.  
  11.     public function __construct($database) {
  12.         $this->database = $database;
  13.     }
  14.  
  15.     public function userExists(Nette\Database\Explorer $database, $user): ?Nette\Database\Table\ActiveRow {
  16.         return $database->table('Users')->where('Name' , $user)->fetch();
  17.     }
  18.  
  19.     public function redirectUser(): void {
  20.         if (!$this->user->isLoggedIn()) {
  21.             $this->flashMessage('Nepřihlášen', 'warning');
  22.             $this->redirect('Homepage:');
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment