christabell's avatar

"Route [posts.show] not defined."

C:\xampp\htdocs\blog\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php ! ($expires && Carbon::now()->getTimestamp() > $expires); }

/**
 * Get the URL to a named route.
 *
 * @param  string  $name
 * @param  mixed   $parameters
 * @param  bool  $absolute
 * @return string
 *
 * @throws \InvalidArgumentException
 */
public function route($name, $parameters = [], $absolute = true)
{
    if (! is_null($route = $this->routes->getByName($name))) {
        return $this->toRoute($route, $parameters, $absolute);
    }

    throw new InvalidArgumentException("Route [{$name}] not defined.");
}

/**
 * Get the URL for a given route instance.
 *
 * @param  \Illuminate\Routing\Route  $route
 * @param  mixed  $parameters
 * @param  bool   $absolute
 * @return string
 *
 * @throws \Illuminate\Routing\Exceptions\UrlGenerationException
 */
protected function toRoute($route, $parameters, $absolute)
{
    return $this->routeUrl()->to(
        $route, $this->formatParameters($parameters), $absolute
    );
}

/**

Arguments "Route [posts.show] not defined." i keep getting this error

0 likes
5 replies
Nakov's avatar

Show the content of your web.php file. Do you have Route::resource('posts', ...);?

Try using php artisan route:list and make sure that you have named route called posts.show.

1 like
munazzil's avatar

In your controller function you have to use return view() instead of return redirect,

    change return redirect()->route('posts.show');

to

      return view('posts.show');
Nakov's avatar

@MUNAZZIL - redirecting to a route is completely valid. The named route does not exist in his case that's the reason for the error.

1 like
munazzil's avatar

@nakov Yes Thank you. Sometime he may use the blade name for his route he wants to post the result for php artisan route:list then will see whats going on that why i show him for return view too with your answer ;).

Please or to participate in this conversation.