Class "App\Models\Book" not found について
今ララベルのudemyで学習をしているのですが、
php artisan serveして、ララベルのトップページに接続した際、not foundとなってしまいます。
文字通りそんなファイルは存在しないという意味なのはわかりますが、ファイルを確認したところあったのでなぜ読み込んでくれないのかわかりません、、
votingテーブルを作りそのあとに紐づけるためのVotingモデルをartisanコマンドで生成したのでそれをトップページに表示したいと思いました。
php artisan make:model Voting
通常ララベルのページはroutes/web.phpに接続しにいった際、resources内のwelcome.blade.phpがデフォルトで表示されると思うのですが、
それを自身が作った、books.blade.phpにしたいと思い、コードを書き換えました。
デフォルトのweb.php
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
/* /(root)はサイトの一番上の階層を示す それを読んだ時に呼び出させる関数*/
Route::get('/', function () {
return view('welcome');
});
書き換えたweb.php
<?php
use Illuminate\Support\Facades\Route;
use APP\Models\Voting;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
$votings = Voting::all();
return view('votings', ['votings' => $votings] );
});
use APP\Models\Voting;を指定して
RouteのところでVotingモデルを$votingの変数に格納してから
view で表示させるように書いたのですが、、