If you copy its content to notepad and delete the file, can you run it?
Aug 16, 2022
4
Level 8
Class not found, but can't use Composer right now, what can I do?
I added a Model class file MyModel.php manually (created the file inside the Models folder, not via artisan).
But now I get error: Class App\Model\MyModel not found when using it from another Model:
public function MyModel() {
return this->hasOne('App\Model\MyModel');
}
and I can't use composer dump-autoload right now which I think could have solved this issue. Is there another way to do it manually?
Thanks!
Level 54
You shouldn't need to run composer dump-autoload when adding classes.
More likely your namespace isn't correct within the Model. Make sure its the same as others in the Models folder.
namespace should match plural App\Models to match your Models directory
1 like
Please or to participate in this conversation.