Test Check
Test Check

Reputation: 119

Class not found on Laravel - Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)

Getting an error - Class 'Ientry' not found on Laravel 5.6. while running page localhost/work/i-upload-panel

My route.php code is below

Route::get('/i-upload-panel', function () {
    (new  Ientry())->importToDb();
        dd('done');
        return view('admin.i-upload-panel');
}
);

Model Ientry.php

<?php

namespace App\Http\Model;

use Illuminate\Database\Eloquent\Model;


class Ientry extends Model
{
     public function importToDb()
     {
        //Function here
     }
}

Upvotes: 0

Views: 1568

Answers (2)

Dilip Hirapara
Dilip Hirapara

Reputation: 15296

As you said it is model then you have to use a namespace with the model then you can create instance of that class.

(new App\Http\Model\Ientry())->importToDb();

or

(new \App\Http\Model\Ientry())->importToDb();

Upvotes: 3

Ewan
Ewan

Reputation: 181

It looks you're attempting to use an imported as opposed to a fully qualified reference to it. The route files don't normally have a namespace declaration, so the best bet would be to explicitly reference.

It would be something like:

(new \App\Model\Ientry())->importToDb();

Upvotes: 1

Related Questions