1 month ago

Models is Not Working in Laravel 8

Posted 1 month ago by Araw

I am new in laravel please help me

My table Name is : products

++++++++++++++++++++++++Model File is Product.php ++++++++++++++++++++++++


namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
    use HasFactory;


++++++++++++++++++++++++++++++Controller File ProductsController.php ++++++++++++


namespace App\Http\Controllers;
use App\Product;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ProductsController extends Controller
    public function index(){
          $products = Product::all();
          return view('allproducts',compact('products'));


i got the Error

Error Class 'App\Product' not found

Please sign in or create an account to participate in this conversation.