首页 文章

与Laravel 4中相同模型的关系

提问于
浏览
0

我正在尝试使用相同的模型/表配置关系,但Laravel会返回错误: timeout .

表:集合

  • id

  • collection_id

  • 名字

  • 说明

  • 有效

  • 时间戳......

型号/关系:收藏

/* ----------------------------------------------------------------------------
| Relationships
| -----------------------------------------------------------------------------
|
| Relacionamentos
|
*/
/**
* collection method
* Coleção pode pertencer a outra coleção
*
* @access public
* @return void
* @since 1.0
* @version 1.0
* @author Patrick Maciel
*/
public function collection()
{
return $this->belongsTo('Collection');   
}

/**
* collections method
* Coleção pode ter várias sub-coleções
*
* @access public
* @return void
* @since 1.0
* @version 1.0
* @author Patrick Maciel
*/
public function collections()
{
    return $this->hasMany('Collection');    
}

错误

Timeout try relationship with same model

如何解决get get(parent)和collections(children)的问题?谢谢

1 回答

  • 0

    你尝试过hasOne而不是belongsTo吗?

相关问题