Home » Php » FatalThrowableError Class 'App\Models\Patient' not found in laravel 5.4

FatalThrowableError Class 'App\Models\Patient' not found in laravel 5.4

Posted by: admin June 30, 2018 Leave a comment

Questions:

I have created a model by using the command php artisan make:model Patient. The command creates a model named Patient in the app folder.

In Model Patient:

namespace App;

use Illuminate\Database\Eloquent\Model;

class Patient extends Model
{
    //
    public function getPurchaseOrder(){
        return "Hello World";        
    }
}

In Controller PatientController:

namespace App\Http\Controllers;
class PatientController extends Controller
{
  protected $patientModel;

public function __construct(Request $request, PatientInterface $patient)
    {
        parent::__construct($request);        
        $this->patientModel = new \App\Patient();
    }

   public function test(){
     echo $this->patientModel->getPurchaseOrder();
  }

}

It’s working fine. The problem is when I create a folder named Models inside the app folder and move Patient model then call the model function it gives an error:

FatalThrowableError Class 'App\Models\Patient' not found

Any help will be appreciated.

Answers: