0
今天我遇到了一个奇怪的问题。 我有一个非常复杂的数据库,有很多关系。 在我的模型,我得到athe以下功能:开启模型属性不起作用 - laravel 4
public function resource(){
dd($this->getAttributes());
switch($this->content_type){
case Content::TYPE_TASKLIST:
return $this->belongsTo('Tasklist', 'content_id');
case Content::TYPE_FEEDBACK:
return $this->belongsTo('Feedback', 'content_id');
case Content::TYPE_SURVEY:
return $this->belongsTo('Survey', 'content_id');
case Content::TYPE_MEMO:
return $this->belongsTo('Memo', 'content_id');
case Content::TYPE_GEAR:
return $this->belongsTo('Gear', 'content_id');
}
return $this->belongsTo('Resource', 'content_id');
}
此功能必须改变的关系,并给我一个好得到正确的信息。 我检查了千次列的名称,但我无法使开关工作。
$ this-> content_type始终为空,因此它不会更改关系。 我尝试了很多。正如你所看到的,我dd()模型属性,但它只返回一个空数组。
我不明白为什么这个功能不起作用。所有其他realtions我得到,直到这些différentskind od资源是好的。我得到了关于资源ID和内容类型的紧密信息,但根本不起作用。
有人知道为什么吗?
谢谢。