前提・実現したいこと
初学者です。laravelでアプリを作っています。お店の投稿画面作成中にclassが存在しないというエラーで詰まっています。色々ググって同じようなエラーの対処法などを行ってみましたがエラー解消できませんでしたので投稿させていただきました。どうかよろしくお願いいたします。
発生している問題・エラーメッセージここに言語を入力
Target class [App\Http\Controllers\ShopControlle] does not exist.
### 該当のソースコード PHP ShopController.php <?php namespace App\Http\Controllers; use App\Shop; use Illuminate\Http\Request; class ShopController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //shopモデルのデータを全て取り出して、indexビューに送る $shops = Shop::all(); return view('index', ['shops' => $shops]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\Shop $shop * @return \Illuminate\Http\Response */ public function show(Shop $shop) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\Shop $shop * @return \Illuminate\Http\Response */ public function edit(Shop $shop) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Shop $shop * @return \Illuminate\Http\Response */ public function update(Request $request, Shop $shop) { // } /** * Remove the specified resource from storage. * * @param \App\Models\Shop $shop * @return \Illuminate\Http\Response */ public function destroy(Shop $shop) { // } }
PHP Shop.php <?php namespace App; use Illuminate\Database\Eloquent\Model; class Shop extends Model { //shopモデルとcategoryモデルの関連付 public function category() { //belongToは所属する return $this->belongsTo('App\Category'); } }
PHP web.php <?php //ドメイン名に続けてshopsの場合shopControllerのindexメソッドを呼び出す Route::get('/shops', 'App\Http\Controllers\ShopControlle@index')->name('shop.list'); Route::get('/', function () { return redirect('/shops'); });
PHP index.blade.php <!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bestラーメン</title> <style> body { padding: 10px } ; </style> </head> <body> <h1>お店一覧</h1> @foreach ($shops as $shop) <p> {{ $shop->category->name }}, {{ $shop->name}}, {{$shop->addres}} </p> @endforeach </body> </html>
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
PHP 8.0.3
Laravel Framework 8.67.0
ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/10/23 22:26