Laravel class not found with one-to-many Laravel class not found with one-to-many php php

Laravel class not found with one-to-many


In order for this to work, I needed to fully qualify the EstimateProject string in my EstimateContract model.

The solution was to change it from:

return $this->hasMany('EstimateProject', 'contractId'); 

to

return $this->hasMany('\Test\Tools\EstimateProject', 'contractId');


You have to use the fully qualified name, but I got the same error when I used forward slashes instead of back slashes:

//Correctreturn $this->hasMany('Fully\Qualified\ClassName');//Incorrectreturn $this->hasMany('Fully/Qualified/ClassName');