ChrisF79
3 months ago
339
3
General

Trying to get property 'metainfo' of non-object

Posted 3 months ago by ChrisF79

Hi there,

I just upgraded to Laravel 7 from 6 and I'm getting the error:

ErrorException
Trying to get property 'metainfo' of non-object
http://listingnaples.com/listing/220043611/3325-airport-pulling-road-north-unit-q4-naples-fl-34105

The code that it refers to is:

<?php

namespace App\Http\Middleware;

use Closure;
use Redirect;

class PropertyUrlRedirect
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        // Clean/self-updating URLs for property
        $route = $request->route();
        //dd($route);

        $listing = $route->parameter('listing');

        if ($route->parameter('metainfo') != $listing->metainfo) {
            return Redirect::route('listing.show', [$listing->MLSNumber, $listing->metainfo]);
        }

        return $next($request);
    }
}

It is complaining about the if statement toward the bottom. Why? I can't figure out why it is doing this or how to fix it.

Thank you!

Please sign in or create an account to participate in this conversation.