Add namespace App;
at the top of your Model like so
namespace App;
class Cat extends Model
{
//
protected $fillable = [
'name', 'date_of_birth', 'breed_id',
];
public function breed(){
return $this->belongsTo('Breed');
}
}
I did it and still dont work :( Maybe with Breed Model is some not fine, like in $this->hasMany('Cat'); because error is in Model.php in vendor laravel in this:
public function hasMany($related, $foreignKey = null, $localKey = null)
{
$foreignKey = $foreignKey ?: $this->getForeignKey();
$instance = new $related;
$localKey = $localKey ?: $this->getKeyName();
return new HasMany($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey);
}
in $instance = new $related;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community