Last active
April 13, 2018 09:36
-
-
Save MarGul/46413331b341176cca01fb05c52163f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Document model | |
public function connectedWith() | |
{ | |
return $this->belongsToMany('App\Models\Document', 'connection_document', 'document_id', 'connected_id'); | |
} | |
public function connectedTo() | |
{ | |
return $this->belongsToMany('App\Models\Document', 'connection_document', 'connected_id', 'document_id'); | |
} | |
/** | |
* When this model is converted to an array (JSON response) | |
* | |
* @return array | |
*/ | |
public function toArray() { | |
// When I remove the comments from connectedTo and connectedWith it goes crazy | |
return [ | |
'id' => $this->id, | |
'pages' => $this->pages, | |
//'connectedWith' => $this->connectedWith, | |
//'connectedTo' => $this->connectedTo | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment