<?php namespace App\Filters;

use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;

class LoginFilter implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        if ( ! service('auth')->isLoggedIn()) {
			
            session()->set('redirect_url', current_url());
            
    		return redirect()->to('login')
                     		 ->with('info', 'قم بتسجيل الدخول للمتابعة');
			
		}
    }

    //--------------------------------------------------------------------

    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
    {
        // Do something here
    }
}