3 months ago

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:

Trying to get property 'metainfo' of non-object

The code that it refers to is:


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();

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

        if ($route->parameter('metainfo') != $listing->metainfo) {
            return Redirect::route('', [$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.