Created
November 9, 2020 10:13
-
-
Save renopaslah/5c6fde1e76f4c650cdd769edc941ffb5 to your computer and use it in GitHub Desktop.
Filters no-respon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Controllers; | |
class Cashier extends BaseController | |
{ | |
protected $model; | |
public function __construct() | |
{ | |
// $this->model = new Hrd_model(); | |
} | |
public function index() | |
{ | |
echo 'ini halaman kasir'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Filters; | |
use CodeIgniter\HTTP\RequestInterface; | |
use CodeIgniter\HTTP\ResponseInterface; | |
use CodeIgniter\Filters\FilterInterface; | |
class Cashier_filter implements FilterInterface | |
{ | |
public function before(RequestInterface $request, $arguments = null) | |
{ | |
// return redirect()->to('/login'); | |
echo 'filter berhasil'; | |
} | |
//-------------------------------------------------------------------- | |
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) | |
{ | |
// Do something here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Config; | |
use CodeIgniter\Config\BaseConfig; | |
class Filters extends BaseConfig | |
{ | |
// Makes reading things below nicer, | |
// and simpler to change out script that's used. | |
public $aliases = [ | |
'csrf' => \CodeIgniter\Filters\CSRF::class, | |
'toolbar' => \CodeIgniter\Filters\DebugToolbar::class, | |
'honeypot' => \CodeIgniter\Filters\Honeypot::class, | |
'cashier_level' => \App\Filters\Cashier_filter::class, | |
]; | |
// Always applied before every request | |
public $globals = [ | |
'before' => [ | |
//'honeypot' | |
// 'csrf', | |
], | |
'after' => [ | |
'toolbar', | |
//'honeypot' | |
], | |
]; | |
// Works on all of a particular HTTP method | |
// (GET, POST, etc) as BEFORE filters only | |
// like: 'post' => ['CSRF', 'throttle'], | |
public $methods = []; | |
// List filter aliases and any before/after uri patterns | |
// that they should run on, like: | |
// 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']], | |
public $filters = [ | |
'cashier_level' => ['before' => ['cashier/*']], | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment