dst3605528 2015-09-21 17:02 采纳率: 0%
浏览 54
已采纳

找不到“App \ Http \ Controllers \ Restaurant”类

I am facing this issue which i wanted to insert data into restaurants, but it keep showing error

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests\FoodRequest; use App\Http\Controllers\Controller;
   public function store(FoodRequest $request)
    { 
        Restaurant  ::create($request->all());
        return redirect()->back(); 
    }
  • 写回答

2条回答 默认 最新

  • doudandui1592 2015-09-21 21:00
    关注

    You are trying to use the Restaurant model. Models are usually under the App namespace.

    To use your Restaurant mode, you must write this at the top of your controller:

    use App\Restaurant;
    

    PHP automatically looks for classes with the given name in the same namespace if it is not imported. You were looking for a class called Restaurant in App\Http\Controllers, when actually it exists in App

    Hope this helps you!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题