Araw
2 weeks ago
226
7
Laravel

Models is Not Working in Laravel 8

Posted 2 weeks ago by Araw

I am new in laravel please help me

My table Name is : products

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

<?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 ++++++++++++

<?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 http://127.0.0.1:8000/products

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