1
I have an app running Laravel 4.2
, I have a class that takes care of IP's
in a blacklist
, and this one is safe on the bench.
I need that when a user accesses my application the system validates if the IP
is in the blacklist
returns a 403, if you won’t let me in. I’m trying to instantiate the class BlackListIpController
inside the archive bootstrap/start.php
(file that starts the application) however, without success.
Code:
$model = new app\controllers\BlackListIPsController;
if($model::where('ip', $model->getIp())->first()) {
abort(403);
}
Error:
[Fri Jun 9 09:19:18 2017] PHP Fatal error: Undefined Constant 'app controllers Blacklistipscontroller' in /home/user/projects/abc/bootstrap/start.php on line 16
[Fri Jun 9 09:36:53 2017] PHP Fatal error: Class 'app controllers Blacklistipscontroller' not found in /home/user/projects/abc/bootstrap/start.php on line 16
If you have to create a filter in the case of Laravel
– novic
Oh cool, can you give me a hand of how I do it ?
– Danilo Tiago Thai Santos
You can create a middleware to treat this.
– Kayo Bruno
@Kayobruno does not have middleware in 4.2 is filter!
– novic
@Danilotiagothaisantos made an example ... !!!
– novic
@Virgilionovic Vlws for warning bro, did not know this. I only worked with Laravel 5.x
– Kayo Bruno