Answers for "must return a relationship instance, but "null" was returned. Was the "return" keyword used? in file /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 492"

PHP
1

must return a relationship instance, but "null" was returned. Was the "return" keyword used? in file /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 492

//ERROR -> ..must return a relationship instance, but "null" was returned. Was the "return" keyword used? in file /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 492
public function seller() {
	$this->belongsTo(Seller::class);
}

//SOLUTION -> Check in your relationships if you don't forgot the "return"
public function seller() {
	return $this->belongsTo(Seller::class);
}
Posted by: Guest on August-06-2021

Code answers related to "must return a relationship instance, but "null" was returned. Was the "return" keyword used? in file /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 492"

Browse Popular Code Answers by Language