我创建了两个资源控制器,一个用于管理员,另一个用于用户。
我得到的错误是,
Illuminate\Contracts\Container\BindingResolutionException 目标类 [App\Http\Controllers\ProductsController] 不存在。
我的代码有什么问题?
这是我的 Admin\ProductsController.php
<?php
namespace 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');
}
繁华开满天机