找不到“ App \ Http \ Controllers \ Product”的类路径

时间:2019-01-27 11:52:40

标签: laravel-5

这是我的产品负责人

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;

  class ProductController extends Controller
  {
    public function index(){

    }
    public function create(){
        return view('admin.products.create');
    }
    public function store(Request $request){
        // validate the form
        $request->validate([
            'name'=>'required',
            'price'=>'required',
            'description'=>'required',
            'image'=>'image|required'
        ]);
        // upload the image
        if($request->hasFile('image')){
            $image=$request->image;
            $image->move('uploads',$image->getClientOriginalName());
        }

        // save the data into database
        Product::create([
            'name'=>$request->name,
            'price'=>$request->price,
            'description'=>$request->description,
            'image'=>$request->image->getClientOriginalName()
        ]);

        // session message
        $request->session()->flash('msg','Your Product has been added');
        // redirect
        return redirect('products/create');
    }

I am not able to upload and save data on mysql database}

1 个答案:

答案 0 :(得分:1)

调用<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="restrictedLengthString"> <xs:restriction base="xs:string"> <xs:maxLength value="10"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="boundedInteger"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0" /> <xs:maxInclusive value="10" /> </xs:restriction> </xs:simpleType> <xs:element name="foo"> <xs:complexType> <xs:simpleContent> <xs:extension base="restrictedLengthString"> <xs:attribute name="bar" type="boundedInteger"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema> 表示您正在使用模型,因此必须在Product::create()中包含产品模型