MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

Auth::check() at middleware

error

!Auth::check() in the middleware to check if user is logged in or not, i am trying to get property of non-object but it shows an error like below: at => /Http/Middleware/VerifyCsrfToken.php $response->headers->setCookie

 admin middleware:

public function handle($request, Closure $next) { if (!Auth::check()) { return “Permission Denied.”; } return $next($request); }

Solution:

The error is encountering, “trying to get property of non-object,” suggests that the $response variable in the middleware is not an object as expected. To resolve this issue, you need to return an instance of a response object instead of a string. Here’s an updated version of your code:

Instead of returning a string, the middleware should return an instance of a response object. To achieve this, please consider the following approach:

public function handle($request, Closure $next) { if (!Auth::check()) { return response(‘Permission Denied.’, 401); } return $next($request); }

Related Posts

AWS Certification Training: Hands-On Guide to Cloud Mastery

In a world where businesses live or die by their ability to scale instantly, Amazon Web Services (AWS) isn’t just a tool—it’s a career superpower. From startups…

Master AWS: Expert-Led Cloud Training & Certification

The digital landscape is transforming, and at the heart of this transformation is the cloud. For IT professionals, mastering Amazon Web Services (AWS) is no longer a…

AWS Certification Training: Master Cloud Skills for Career Success

In an era where cloud computing drives digital transformation, Amazon Web Services (AWS) remains the cornerstone of enterprise-grade infrastructure. With over 200 integrated services spanning compute, storage,…

Master AWS Certification with Expert-Led Training

In the heart of the modern digital enterprise, the cloud is no longer a mere utility; it is the foundational platform for innovation, agility, and competitive advantage….

Master AWS with Expert-Led Training

In the heart of Europe’s digital landscape, the Netherlands stands as a beacon of innovation. For IT professionals here, the cloud is no longer the future—it’s the…

AWS Training and Certification: Fast Track Your Cloud Success

Building a career in cloud technology is now easier and more rewarding than ever. AWS is the world’s top cloud provider, and learning how to use AWS…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x