I am new to Laravel, so I am trying to store some information coming from a form and I am getting this error:
Class ‘AppHttpControllersProducts’ not found
I have tried adding use products;
but it still doesn’t work…
Here is my code:
Products Controller
namespace AppHttpControllers; use AppHttpControllersProductsController; use Session; use IlluminateHttpRequest; class ProductsController extends Controller { /** * Show the form for creating a new resource. * * @return IlluminateHttpResponse */ public function create() { return view('products.create'); } /** * Store a newly created resource in storage. * * @param IlluminateHttpRequest $request * @return IlluminateHttpResponse */ public function store(Request $request) { $user_id = Session::get('user_id'); //die(var_dump($user_id)); return Products::create([ 'user_id' => $user_id, 'id_template' => $data['id_template'], 'title' => $data['title'], 'metadescription' => $data['metadescription'], 'robots' => $data['robots'], 'canonical' => $data['canonical'], 'product_name' => $data['product_name'], 'product_image' => $data['product_image'], 'product_code' => $data['product_code'], 'price' => $data['price'], 'price_discount' => $data['price_discount'], 'quantity' => $data['quantity'], 'summary' => $data['summary'], 'description' => $data['description'], 'friendly_url' => $data['friendly_url'], 'contact_form' => $data['contact_form'], 'rating' => $data['rating'], 'comments' => $data['comments'], 'discount' => $data['discount'], 'show' => $data['show'], 'active' => $data['active'], ]); } }
Products model
namespace App; use IlluminateDatabaseEloquentModel; class products extends Model { // }
Any help is greatly appreciated.
Advertisement
Answer
In your controller write:
use Appproducts;