Пример #1
0
 protected function validate($inputs = [], $rules = [])
 {
     $this->validator->validate($inputs, $rules);
     if (!$this->validator->passed()) {
         return Redirect::back(['errors' => $this->validator->errors()]);
     }
 }
Пример #2
0
 public function getLogout()
 {
     if (Auth::check()) {
         Session::delete(Config::get('session.name'));
     }
     return Redirect::to('/');
 }
Пример #3
0
 public function getLogin()
 {
     if (Session::exists(Config::get('session.name'))) {
         return Redirect::to('/');
     }
     return view('auth.login');
 }
Пример #4
0
use App\Core\Session;
use App\Core\Config;
use App\Core\Redirect;
use App\Core\Middleware;
$middleware = new Middleware();
/**
 * Berhubung isu method next pada Middleware.
 * Sekarang hanya bisa menggunakan before middleware/filter. 
 * Note: Dikarenakan fungsi exit() pada helper view().
 */
$middleware->add('auth', function ($params) use($middleware) {
    // echo "auth <br>";
    if (!Session::exists(Config::get('session.name'))) {
        if (is_ajax()) {
            http_response_code(401);
            exit;
        } else {
            Redirect::route('get-login');
        }
    }
    $middleware->next($params);
});
$middleware->add('admin', function ($params) use($middleware) {
    // do something
    $middleware->next($params);
});
$middleware->add('something', function ($params) use($middleware) {
    // do something
    $middleware->next($params);
});
$GLOBALS['middleware'] = $middleware;