Несмотря на то, что реализовано много отношений L4, и они работают большую часть времени. Я борюсь и по какой-то причине не вижу, где я ошибся. Это почти наверняка что-то очевидное.Laravel 4.2 oneToMany issue issue
Отношения в том, что задача состоит из одной темы, темы имеют много задач.
Задача Модель
class Task extends Eloquent {
protected $guarded = array();
public static $rules = array(
);
public function resources()
{
return $this->belongsToMany('Resource');
}
public function topic()
{
return $this->belongsTo('Topic', 'topic_id');
}
}
Тема Модель
class Topic extends Eloquent {
protected $guarded = array();
public static $rules = array();
public function tasks()
{
return $this->hasMany('Task');
}
}
Задача контроллера
public function show($id)
{
$task = $this->task->where('number', $id);
return View::make('tasks.show', compact('task'));
}
когда я д.д. ($ задание) массив отношений пуст.
объект (Задача) # 688 (21) {[ "охраняются": защита] => массив (0) {} [ "соединение": защита] => NULL, [ "таблица": защита] = > NULL ["primaryKey": protected] => string (2) "id" ["perPage": protected] => int (15) ["incrementing"] => bool (true) ["timestamps"] = > bool (true) ["attributes": protected] => array (11) {["id"] => string (1) "9" ["number"] => string (1) "6" [ "topic"] => string (1) "2" ["topic_old"] => string (10) "War Effort" ["task"] => string (28) "Вы хотите, чтобы мы собрали Мосс?" ["object"] => string (36) "Сбор информации, включая Q & A" ["method"] => string (29) "Поддерживаемые исторические исследования" ["context"] => string (0) "" ["level"] => string (0) "" ["created_at"] => string (19) "0000-00-00 00:00:00" ["updated_at"] => string (19) " 0000-00-00 00:00:00 "} [" original ": protected] => array (11) {[" id "] => строка (1)" 9 "[" number "] => string (1) «6» ["topic"] => string (1) "2" ["topic_old"] => string (10) "War Effort" ["task"] => string (28) "You хочу нас собирать Мосса? ["object"] => string (36) "Сбор Информация, включающая Q & A" ["method"] => string (29) "Поддерживается историческое исследование" ["context"] => string (0) "" ["level"] => string (0) "" ["created_at"] => string (19) "0000-00-00 00:00:00" ["updated_at"] => string (19) " 0000-00-00 00:00:00 "} [" relations ": protected] => array (0) {} [" hidden ": protected] => array (0) {} [" visible ": protected] => array (0) {} ["appends": protected] => array (0) {} ["fillable": protected] => array (0) {} ["date": protected] => array (0) { } ["touches": protected] => array (0) {} ["observables": protected] => array (0) {} ["with": protected] => array (0) {} ["morphClass": protected] => NULL ["exi НТО "] => BOOL (истина) [" softDelete ": защита] => BOOL (ложь)}
Таблица задач DB имеет 'topic_id' – latitudehopper