php - Class 'Model' not found. Try importing this class: IlluminateDatabaseEloquentModel
Get the solution ↓↓↓I've been getting a couple of errors when I'm trying to turn a static page into a dynamic one. When I'm importing a class into myabout
controller, I am getting some errors which I managed to fix but not all. This is the code in my about controller.
namespace App\Http\Controllers;
use App\Models\About;
use Illuminate\Http\Request;
class AboutController extends Controller
{
public function about()
{
$abouts = Model::all();
return view('/about', compact('abouts'));
}
}
This is the code on theweb.php
file:
Route::get('/about', [App\Http\Controllers\AboutController::class, 'about'])
->name('about');
And the code from my about model:
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class About extends Model
{
use HasFactory;
protected $table = 'abouts';
protected $fillable = ["title","image","description"];
}
Plus the code from about.blade.php
<div class="row align-items-center mr-5">
@foreach($abouts as $about)
<div class="col-lg-6 py-5 px-5"></div>
<div class="col-lg-6 pl-lg-5 ">
<h3 class=" font-weight-bold">About Us</h3>
<p class="text-justify pt-3 mr-5">Text.</p>
<p class="text-justify pt-3 mr-5">Text.</p>
</div>
</div>
@endforeach
Can someone help me figure out what is wrong and what is throwing the errorClass 'Model' not found
?
I tried importing this class:Illuminate\Database\Eloquent\Model
. I just started learning Laravel a few months ago so I have limited knowledge about the framework.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: uncaught error: call to undefined function mysqli_connect()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.