【问题标题】:Class 'App\Http\Controllers\customer' not found Laravel 5.2Laravel 5.2 未找到“App\Http\Controllers\customer”类
【发布时间】:2018-03-16 17:37:27
【问题描述】:
<?php
        namespace App\Http\Controllers;
        use Illuminate\Http\Request;
        use App\Http\Controllers\customer;
        use App\Http\Requests;

        class CustomerController extends Controller
        {
        public function index()
        {
        return view('insert');
        }
        public function create()
        {

        }
        public function store(Request $request)
        {

        $customer = new customer;
        $customer->name = $request->name;
        $customer->sex = $request->sex;
        $customer->pob = $request->pob;
        $customer->tel = $request->tel;
        $customer->email = $request->email;
        $customer->save();
        }


         public function show()
           {

        return view('show');


           }
        }
?>

我收到错误 Class 'App\Http\Controllers\customer' not found Laravel 5.2
我用过 App\customer; 使用输入; 为什么我会出错? 代码有什么问题?

【问题讨论】:

    标签: php laravel laravel-5 laravel-5.2


    【解决方案1】:

    如果你的customer 类在App 命名空间中,你需要使用:

    use App\customer;
    

    而不是

    use App\Http\Controllers\customer;
    

    【讨论】:

      【解决方案2】:

      这很简单,您需要了解。确保您已经在 app/Customer.php 中创建了一个模型 Customer.php,而另一件重要的事情是您必须创建包含客户的表。之后,您需要在类之前添加这一行,例如:-

      use App\Customer;
      

      希望对你有帮助:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-09
        • 1970-01-01
        • 1970-01-01
        • 2018-04-02
        • 2015-06-24
        • 2021-09-25
        • 2015-05-21
        • 2015-08-31
        相关资源
        最近更新 更多