I'm currently in the process of upgrading a Laravel 4.2 project to 5.0 I've been making reasonable progress until this particular error:
FatalErrorException in Model.php line 750: Class 'SAPProduct' not found.
My SapProduct class is called from my Product class with a hasOne relationship and I can't work out why Laravel can't find it.
SapProduct.php
namespace App\Models;
use Eloquent;
class SapProduct extends Eloquent
{
public function brand()
{
return $this->belongsTo('App\Models\Brand', 'U_Brand', 'Name');
}
}
Product.php
namespace App\Models;
use Eloquent;
class Product extends Eloquent
{
...
public function sapProduct()
{
$relationship = $this->hasOne('App\Models\SapProduct', 'ItemCode', 'itemcode');
}
...
}
Model.php (lines 746-755)
public function hasOne($related, $foreignKey = null, $localKey = null)
{
$foreignKey = $foreignKey ?: $this->getForeignKey();
$instance = new $related;
$localKey = $localKey ?: $this->getKeyName();
return new HasOne($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey);
}
I apologise if I'm missing any other necessary information, I'll add more as/if requested.
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire