1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Laravel】Class "App\モデル名" not found

Posted at

環境

Laravel v9.5.1 (PHP v8.1.3)

状況

コントローラーにAricleモデルを宣言した際のエラー

Class "App\Article" not found
app/Http/Controllers/HomeController.php
...
use App\Article;

class HomeController extends Controller
{
  ...
}

解決方法

ちゃんとディレクトリ通りに参照する。
古いバージョンの記事を参考にしていたため、自分のバージョンに合った記事を参考にする。

app/Http/Controllers/HomeController.php
...
use App\Models\Article;

class HomeController extends Controller
{
  ...
}

いちいちモデル宣言しなきゃいけないの面倒だな…

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?