Tuesday, March 14, 2017

Laraval: Eloquent / Tinker Class not found

Im trying to get data in a relationship with tinker. I get an error that says Class 'App\Date' not found. I think cause I am not using the right code, but I have no idea what code I need.

I have 2 models:

Contact (app\Models\Contact.php)
Date (app\Models\Date.php)

Contact

public function dates(){
   return $this->hasMany(Date::class);
}

Tinker

php artisan tinker

$test = App\Models\Contact::find(516);

$test returns a user.
If I uses $test->dates after that I get an error saying this:

[Symfony\Component\Debug\Exception\FatalErrorException]Class 'App\Date' not found



via Koen van de Sande

Advertisement