Я пытаюсь обновить существующий проект Laravel 4 до версии 5. Модельные отношения не работают нормально. Каждый раз, когда я пытаюсь получить доступ к свойству из таблицы property_price
, он возвращает null.Обновление Laravel от 4 до 5: неработающие отношения
Мои модели находятся в каталоге App/Models
.
Модель недвижимости
class Property extends \Eloquent {
protected $guarded = array('id');
protected $table = 'properties';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $softDelete = true;
public function propertyPrice()
{
return $this->hasOne('PropertyPrice','pid');
}
}
PropertyPrice Модель
class PropertyPrice extends \Eloquent {
protected $guarded = array('id');
protected $table = 'property_pricing';
public function property()
{
return $this->belongsTo('Property');
}
}
Использование
$property = Property::find($id);
$price = $property->property_price->per_night_price; // null
трески e работает нормально в Laravel 4.
Вы модель имена? –