shetabit / visitor

a laravel package to work with visitors and retrieve their informations
MIT License
527 stars 68 forks source link

Except is not working correctly #28

Closed danielreales7 closed 3 years ago

danielreales7 commented 3 years ago

I have in except: 'except' => ['login','register','admin'] but it's not working correctly.

image

Sometimes works well and sometimes it doesn't.

Routes web:

image

And I have another file with admin routes:

image

What I can be doing wrong?

khanzadimahdi commented 3 years ago

I think it's because of redirection.

khanzadimahdi commented 3 years ago

please check the below file (middleware)

https://github.com/shetabit/visitor/blob/master/src/Middlewares/LogVisits.php

danielreales7 commented 3 years ago

please check the below file (middleware)

https://github.com/shetabit/visitor/blob/master/src/Middlewares/LogVisits.php

I think so... but I can't modify this file. I published the file but I have this error:

image

How can I fix the redirect? Thank you so much!

khanzadimahdi commented 3 years ago

remove LogVisits middleware from your middlewares. create a new middleware and use it instead.

danielreales7 commented 3 years ago

remove LogVisits middleware from your middlewares. create a new middleware and use it instead.

I still don't understand why the url /admin stores me in the database.

image

Although I have commented the middleware it keeps registering events for me.

danielreales7 commented 3 years ago

remove LogVisits middleware from your middlewares. create a new middleware and use it instead.

Only save data when route is /admin ... is so strange. If I reload any other route within admin it doesn't save anything.

image

khanzadimahdi commented 3 years ago

remove LogVisits middleware from your middlewares. create a new middleware and use it instead.

I still don't understand why the url /admin stores me in the database.

image

Although I have commented the middleware it keeps registering events for me.

this action is impossible. have you cached your routes?

khanzadimahdi commented 3 years ago

you can see middleware in the below link

https://github.com/shetabit/visitor/blob/master/src/Middlewares/LogVisits.php

and we don't have any auto-registering middleware in our provider. I think this is because of Laravel's route cache.

the provider is in the below path

https://github.com/shetabit/visitor/blob/master/src/Provider/VisitorServiceProvider.php

danielreales7 commented 3 years ago

you can see middleware in the below link

https://github.com/shetabit/visitor/blob/master/src/Middlewares/LogVisits.php

and we don't have any auto-registering middleware in our provider. I think this is because of Laravel's route cache.

the provider is in the below path

https://github.com/shetabit/visitor/blob/master/src/Provider/VisitorServiceProvider.php

Ohhhh! I understand what is happening. In the /admin route I show the unique visits:

{{ visitor()->visit()->distinct('ip')->count('ip') }}

This shouldn't create a registry for me, right? I only want to show the unique visits.

Sorry for being so heavy.

danielreales7 commented 3 years ago

you can see middleware in the below link

https://github.com/shetabit/visitor/blob/master/src/Middlewares/LogVisits.php

and we don't have any auto-registering middleware in our provider. I think this is because of Laravel's route cache.

the provider is in the below path

https://github.com/shetabit/visitor/blob/master/src/Provider/VisitorServiceProvider.php

It's works correctly:

image

I think this should be the ideal operation because I would not like to log a visit to count unique visits.

Thank you so much for your help!

khanzadimahdi commented 3 years ago

I think its better to use $this->request->is($yourPattern)

https://laravel.com/docs/8.x/requests#inspecting-the-request-path

danielreales7 commented 3 years ago

I think its better to use $this->request->is($yourPattern)

https://laravel.com/docs/8.x/requests#inspecting-the-request-path

You're right, it was by following the configuration logic.