我创建了两个资源控制器,一个用于管理员,另一个用于用户。我得到的错误是,Illuminate\Contracts\Container\BindingResolutionException 目标类 [App\Http\Controllers\ProductsController] 不存在。我的代码有什么问题?这是我的 Admin\ProductsController.php<?phpnamespace App\Http\Controllers\Admin;use App\Http\Controllers\Controller;use Illuminate\Http\Request;use App\Product;use App\Category;class ProductsController extends Controller{ public function __construct() { $this->middleware('auth'); } public function index() { $arr['products'] = Product::all(); return view('admin.products.index')->with($arr); } public function create() { return view('admin.products.create'); } public function store(Request $request, Product $product) { if($request->prod_image_path->getClientOriginalName()) { $ext =$request->prod_image_path->getClientOriginalName(); $file = date('YmdHis').rand(1,99999).'.'.$ext; $request->prod_image_path->storeAs('public/admin',$file); }else{ $file =''; } $product-> prod_name = $request-> prod_name; $product-> prod_meta_title = $request-> prod_meta_title; $product-> prod_description = $request-> prod_description; $product-> prod_category = $request-> prod_category; $product-> prod_price = $request-> prod_price; $product-> prod_discount = $request-> prod_discount; $product-> prod_image_path = $file; $product->save(); return redirect()->route('admin.products.index'); }
1 回答
繁华开满天机
TA贡献1816条经验 获得超4个赞
我认为您的用户ProductController控制器名称中有拼写错误。
你的实际类名是:ProdutsController
但 Laravel 正在寻找ProductsController
- 1 回答
- 0 关注
- 59 浏览
添加回答
举报
0/150
提交
取消