0
votes

I'm trying configure a relationship with same model/table, but Laravel return a error: timeout.

Table: collections

  • id
  • collection_id
  • name
  • description
  • active
  • timestamps...

Model/Relationship: Collection

/* ----------------------------------------------------------------------------
| 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');    
}

Error

Timeout try relationship with same model

How can I solve that for get collection (parent), and collections (childrens)? Thanks

1
What's the reason for trying to set up multiple relationships for the same table? It looks like you are trying to set it up as a many-to-many and a one-to-many which I don't think makes any sense.user1669496
I want a collection have multiple childrens (collections). It's correct for this situation?Patrick Maciel

1 Answers

0
votes

Did you tried hasOne rather than belongsTo?