LaravelでEloquentORMを使うため下記コントローラーのようによびだそうとしたのですが
Class not found のエラーが発生してます。コーディングを間違えてると思うのですがどこが間違ってるかわからないので知っている方がいたら教えてもらいたいです。
#ソースコード
・MainPageController.php
<?php namespace App\Http\Controllers\crud; use App\Http\Controllers\Controller; use App\database\orm\crud\Product; class MainPageController extends Controller { /** * 指定ユーザーのプロフィール表示 * * @param int $id * @return View */ public function showMainPage() { $products = Product::all(); foreach ($products as $product) { echo $product->name; } return view('crud.main'); } }
・Product.php
<?php namespace App\database\orm\crud; use Illuminate\Database\Eloquent\Model; class Product extends Model { const CREATED_AT = 'creation_date'; const UPDATED_AT = 'last_update'; protected $table = 'products'; protected $primaryKey = 'product_id'; public $incrementing = true; public $timestamps = true; }
・エラーメッセージ
Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Class 'App\database\orm\crud\Product' not found"
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。