0

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
     }
}

2
  • What is Ientry any library? Commented Feb 15, 2020 at 5:10
  • @DilipHirapara No, It is a Model Commented Feb 15, 2020 at 5:12

2 Answers 2

3

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();
Sign up to request clarification or add additional context in comments.

2 Comments

Glad to help you happy coding :)
Must've beat me to it ;)
1

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();

1 Comment

he defined namespace as `\App\Http\Model`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.