<?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'找不到Laravel 5.2 。
我用过App \ customer;
使用输入;
为什么我会收到错误?
代码中有什么问题?
答案 0 :(得分:1)
如果您的customer
类位于App
命名空间中,则需要使用:
use App\customer;
而不是
use App\Http\Controllers\customer;
答案 1 :(得分:0)
这很简单你需要了解。确保你已经在app / Customer.php中创建了一个模型Customer.php,另外一件重要的事情就是必须用所有客户创建你的表。之后你需要在课前添加这一行,如: -
use App\Customer;
希望有所帮助:)