ボールドテキスト### 前提・実現したいこと
PHPフレームワーク LARAVEL入門 第2版を使って勉強しています。
Laravel8を使用しているので本の内容と少し違うようで、「モデルを作成する」箇所でエラーが起こってしまいましたので質問させていただきました。
発生している問題・エラーメッセージ
エラーメッセージ
Illuminate\Contracts\Container\BindingResolutionException
Target class [PersonController] does not exist.
該当のソースコード
laravel
ソースコード
[PersonController.php]
<?php namespace App\Http\Controllers; use App\Models\Person; use Illuminate\Http\Request; class PersonController extends Controller { public function index(Request $request) { $items = Person::all(); return view('person.index', ['items' => $items]); } } [Person.php] <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Person extends Model { use HasFactory; } [index.blade.php] @extends('layouts.helloapp') @section('title', 'Person.index') @section('menubar') @parent インデックスページ @endsection @section('content') <table> <tr><th>Name</th><th>Mail</th><th>Age</th></tr> @foreach (@items as $item) <tr> <td>{{$item->name}}</td> <td>{{$item->mail}}</td> <td>{{$item->age}}</td> </tr> @endforeach </table> @endsection @section('footer') copyright 2020 tuyano. @endsection [web.php] Route::get('person', [PersonController::class, 'index']); ### 試したこと238 ソースコードの確認 ### 補足情報(FW/ツールのバージョンなど) PHP Version 7.4.6 Laravel Framework 8.5.0 P238~241
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。