Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bhhussain's avatar

How to redirect to login page if session required

Hi,

I made booking calendar and it is available for public and if some one want to see the full details then it needs to be redirected to the login page. Now it is taking to the correct page and showing the below error.


Trying to get property 'company' of non-object (View: /var/www/mallnew/resources/views/layouts/admin.blade.php)

Can any one please help me?

Thank you

0 likes
4 replies
Snapey's avatar

not without knowing what you were trying to do at that point

Sounds like the view is expecting some data to be passed, but you are not setting it.

bhhussain's avatar

@snapey Thank you for your reply

Calendar will display only the title and if some one need the full detail then they have to click the title then it will redirect it to the detail page. if session is active then it is working and if there is no session then it is showing error.

My question is how to request for login detail if required to that page?

Snapey's avatar
Snapey
Best Answer
Level 122

Wrap the URL for the calendar in auth middleware, or specify it in the controller for the calendar.

The authentication middleware will take care of directing the user to the login page, and then back again when they are logged in.

Please or to participate in this conversation.