Welcome Guest, Not a member yet? Register   Sign In
How To Add Filter On Specified HTTP Method and Controller in Routes.php?
#1

What I've tried to achieve is add filter on specified http method and controller. Like:

PHP Code:
$rotues->get('/''Home::index', ['filter' => 'user']);
$rotues->post('/''Home::new', ['filter' => 'admin']); 

But when I call the HTTP GET method, the filter is always use admin while I specified that to use user. How could I achieve this? Thanks.
Reply
#2

(This post was last modified: 03-06-2021, 11:53 AM by iRedds.)

I cannot reproduce.
Have you registered the user filter with the admin class?
Reply
#3

Shouldn't it be $routes instead of $rotues?
Reply
#4

(This post was last modified: 03-07-2021, 06:34 PM by simonickalexs.)

(03-06-2021, 08:53 AM)IvanBell Wrote: Shouldn't it be $routes instead of $rotues?

Ah I have typo inserted in the post, but in my code is $routes  Thank you

(03-06-2021, 08:35 AM)iRedds Wrote: I cannot reproduce.
Have you registered the user filter with the admin class?

Yes, and I'm using the 4.0.4 version, and I've found out they fixed it in the latest version https://github.com/codeigniter4/CodeIgni...ssues/3733. But the problem is, if I'm upgrade it, I will encounter with this issue "CI4 Generate Empty String On Query Binding Value On "FALSE" value (codeigniter.com)". This is a big dilemma and chicken and egg for me since I have no choice to upgrade and rewrite the whole code, my God.
Reply
#5

(This post was last modified: 03-08-2021, 12:19 AM by iRedds.)

CI 4.1.1 php 7.3 MySQL 5.5 & MySQL 8  - Works perfect.

What am I doing wrong?

You can use DB events in which to convert bool 2 int

Attached Files Thumbnail(s)
   
Reply




Theme © iAndrew 2016 - Forum software by © MyBB