Answer the question
In order to leave comments, you need to log in
Why doesn't laravel instantiate the class in the controller?
Hello.
I write this code:
Route
Route::get('article/{id}/edit', 'Cms\[email protected]')->name('cms.blog.article.edit');
<?php
namespace App\Http\Controllers\Cms;
use App\Http\Controllers\Controller;
use App\Models\Blog\BlogArticle;
class BlogArticleController extends Controller
{
public function edit(BlogArticle $article)
{
dd($article);
}
}
<?php
namespace App\Http\Controllers\Cms;
use App\Http\Controllers\Controller;
use App\Models\Blog\BlogArticle;
class BlogArticleController extends Controller
{
public function edit($article)
{
dd(BlogArticle::find($article));
}
}
Answer the question
In order to leave comments, you need to log in
Everything turned out to be very simple:
the name of the parameter should not be $article, but $id. {id} is written in the route
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question