| @@ 23-82 (lines=60) @@ | ||
| 20 | * |
|
| 21 | * @property static $this |
|
| 22 | */ |
|
| 23 | trait CommentRelations |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * A comment has one user (inverse relationship of User::comments). |
|
| 27 | * |
|
| 28 | * @return Relations\BelongsTo |
|
| 29 | */ |
|
| 30 | public function user() |
|
| 31 | { |
|
| 32 | return $this->belongsTo('\Tinyissue\Model\User', 'created_by'); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * A comment has belongs to an issue. |
|
| 37 | * |
|
| 38 | * @return Relations\BelongsTo |
|
| 39 | */ |
|
| 40 | public function issue() |
|
| 41 | { |
|
| 42 | return $this->belongsTo('\Tinyissue\Model\Project\Issue', 'issue_id'); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Comment can have many attachments. |
|
| 47 | * |
|
| 48 | * @return Relations\HasMany |
|
| 49 | */ |
|
| 50 | public function attachments() |
|
| 51 | { |
|
| 52 | return $this->hasMany('Tinyissue\Model\Project\Issue\Attachment', 'comment_id'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Comment can have one activity. |
|
| 57 | * |
|
| 58 | * @return Relations\HasOne |
|
| 59 | */ |
|
| 60 | public function activity() |
|
| 61 | { |
|
| 62 | return $this->hasOne('Tinyissue\Model\User\Activity', 'action_id'); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Comment can have many messages queue. |
|
| 67 | * |
|
| 68 | * @return Relations\HasMany |
|
| 69 | */ |
|
| 70 | public function messagesQueue() |
|
| 71 | { |
|
| 72 | return $this->morphMany('Tinyissue\Model\Message\Queue', 'model'); |
|
| 73 | } |
|
| 74 | ||
| 75 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
|
| 76 | ||
| 77 | abstract public function hasOne($related, $foreignKey = null, $localKey = null); |
|
| 78 | ||
| 79 | abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
| 80 | ||
| 81 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
| 82 | } |
|
| 83 | ||
| @@ 24-73 (lines=50) @@ | ||
| 21 | * |
|
| 22 | * @property static $this |
|
| 23 | */ |
|
| 24 | trait NoteRelations |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Note created by a user. |
|
| 28 | * |
|
| 29 | * @return Relations\BelongsTo |
|
| 30 | */ |
|
| 31 | public function createdBy() |
|
| 32 | { |
|
| 33 | return $this->belongsTo('Tinyissue\Model\User', 'created_by'); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Note belong to a project. |
|
| 38 | * |
|
| 39 | * @return Relations\BelongsTo |
|
| 40 | */ |
|
| 41 | public function project() |
|
| 42 | { |
|
| 43 | return $this->belongsTo('Tinyissue\Model\Project', 'project_id'); |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Note has a user activity record. |
|
| 48 | * |
|
| 49 | * @return Relations\HasOne |
|
| 50 | */ |
|
| 51 | public function activity() |
|
| 52 | { |
|
| 53 | return $this |
|
| 54 | ->hasOne('Tinyissue\Model\User\Activity', 'action_id') |
|
| 55 | ->where('type_id', '=', Model\Activity::TYPE_NOTE); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Note can have many messages queue. |
|
| 60 | * |
|
| 61 | * @return Relations\HasMany |
|
| 62 | */ |
|
| 63 | public function messagesQueue() |
|
| 64 | { |
|
| 65 | return $this->morphMany('Tinyissue\Model\Message\Queue', 'model'); |
|
| 66 | } |
|
| 67 | ||
| 68 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
|
| 69 | ||
| 70 | abstract public function hasOne($related, $foreignKey = null, $localKey = null); |
|
| 71 | ||
| 72 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
| 73 | } |
|
| 74 | ||
| @@ 23-79 (lines=57) @@ | ||
| 20 | * |
|
| 21 | * @property static $this |
|
| 22 | */ |
|
| 23 | trait RelationTrait |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * A comment has one user (inverse relationship of User::comments). |
|
| 27 | * |
|
| 28 | * @return Relations\BelongsTo |
|
| 29 | */ |
|
| 30 | public function user() |
|
| 31 | { |
|
| 32 | return $this->belongsTo('\Tinyissue\Model\User', 'created_by'); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * A comment has belongs to an issue. |
|
| 37 | * |
|
| 38 | * @return Relations\BelongsTo |
|
| 39 | */ |
|
| 40 | public function issue() |
|
| 41 | { |
|
| 42 | return $this->belongsTo('\Tinyissue\Model\Project\Issue', 'issue_id'); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Comment can have many attachments. |
|
| 47 | * |
|
| 48 | * @return Relations\HasMany |
|
| 49 | */ |
|
| 50 | public function attachments() |
|
| 51 | { |
|
| 52 | return $this->hasMany('Tinyissue\Model\Project\Issue\Attachment', 'comment_id'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Comment can have one activity. |
|
| 57 | * |
|
| 58 | * @return Relations\HasOne |
|
| 59 | */ |
|
| 60 | public function activity() |
|
| 61 | { |
|
| 62 | return $this->hasOne('Tinyissue\Model\User\Activity', 'action_id'); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Comment can have many messages queue. |
|
| 67 | * |
|
| 68 | * @return Relations\HasMany |
|
| 69 | */ |
|
| 70 | public function messagesQueue() |
|
| 71 | { |
|
| 72 | return $this->morphMany('Tinyissue\Model\Message\Queue', 'model'); |
|
| 73 | } |
|
| 74 | ||
| 75 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
|
| 76 | abstract public function hasOne($related, $foreignKey = null, $localKey = null); |
|
| 77 | abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
| 78 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
| 79 | } |
|
| 80 | ||
| @@ 24-71 (lines=48) @@ | ||
| 21 | * |
|
| 22 | * @property static $this |
|
| 23 | */ |
|
| 24 | trait RelationTrait |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Note created by a user. |
|
| 28 | * |
|
| 29 | * @return Relations\BelongsTo |
|
| 30 | */ |
|
| 31 | public function createdBy() |
|
| 32 | { |
|
| 33 | return $this->belongsTo('Tinyissue\Model\User', 'created_by'); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Note belong to a project. |
|
| 38 | * |
|
| 39 | * @return Relations\BelongsTo |
|
| 40 | */ |
|
| 41 | public function project() |
|
| 42 | { |
|
| 43 | return $this->belongsTo('Tinyissue\Model\Project', 'project_id'); |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Note has a user activity record. |
|
| 48 | * |
|
| 49 | * @return Relations\HasOne |
|
| 50 | */ |
|
| 51 | public function activity() |
|
| 52 | { |
|
| 53 | return $this |
|
| 54 | ->hasOne('Tinyissue\Model\User\Activity', 'action_id') |
|
| 55 | ->where('type_id', '=', Model\Activity::TYPE_NOTE); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Note can have many messages queue. |
|
| 60 | * |
|
| 61 | * @return Relations\HasMany |
|
| 62 | */ |
|
| 63 | public function messagesQueue() |
|
| 64 | { |
|
| 65 | return $this->morphMany('Tinyissue\Model\Message\Queue', 'model'); |
|
| 66 | } |
|
| 67 | ||
| 68 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
|
| 69 | abstract public function hasOne($related, $foreignKey = null, $localKey = null); |
|
| 70 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
| 71 | } |
|
| 72 | ||
| @@ 23-79 (lines=57) @@ | ||
| 20 | * |
|
| 21 | * @property static $this |
|
| 22 | */ |
|
| 23 | trait RelationTrait |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * A comment has one user (inverse relationship of User::comments). |
|
| 27 | * |
|
| 28 | * @return Relations\BelongsTo |
|
| 29 | */ |
|
| 30 | public function user() |
|
| 31 | { |
|
| 32 | return $this->belongsTo('\Tinyissue\Model\User', 'created_by'); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * A comment has belongs to an issue. |
|
| 37 | * |
|
| 38 | * @return Relations\BelongsTo |
|
| 39 | */ |
|
| 40 | public function issue() |
|
| 41 | { |
|
| 42 | return $this->belongsTo('\Tinyissue\Model\Project\Issue', 'issue_id'); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Comment can have many attachments. |
|
| 47 | * |
|
| 48 | * @return Relations\HasMany |
|
| 49 | */ |
|
| 50 | public function attachments() |
|
| 51 | { |
|
| 52 | return $this->hasMany('Tinyissue\Model\Project\Issue\Attachment', 'comment_id'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Comment can have one activity. |
|
| 57 | * |
|
| 58 | * @return Relations\HasOne |
|
| 59 | */ |
|
| 60 | public function activity() |
|
| 61 | { |
|
| 62 | return $this->hasOne('Tinyissue\Model\User\Activity', 'action_id'); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Comment can have many messages queue. |
|
| 67 | * |
|
| 68 | * @return Relations\HasMany |
|
| 69 | */ |
|
| 70 | public function messagesQueue() |
|
| 71 | { |
|
| 72 | return $this->morphMany('Tinyissue\Model\Message\Queue', 'model'); |
|
| 73 | } |
|
| 74 | ||
| 75 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
|
| 76 | abstract public function hasOne($related, $foreignKey = null, $localKey = null); |
|
| 77 | abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
| 78 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
| 79 | } |
|
| 80 | ||
| @@ 24-71 (lines=48) @@ | ||
| 21 | * |
|
| 22 | * @property static $this |
|
| 23 | */ |
|
| 24 | trait RelationTrait |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Note created by a user. |
|
| 28 | * |
|
| 29 | * @return Relations\BelongsTo |
|
| 30 | */ |
|
| 31 | public function createdBy() |
|
| 32 | { |
|
| 33 | return $this->belongsTo('Tinyissue\Model\User', 'created_by'); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Note belong to a project. |
|
| 38 | * |
|
| 39 | * @return Relations\BelongsTo |
|
| 40 | */ |
|
| 41 | public function project() |
|
| 42 | { |
|
| 43 | return $this->belongsTo('Tinyissue\Model\Project', 'project_id'); |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Note has a user activity record. |
|
| 48 | * |
|
| 49 | * @return Relations\HasOne |
|
| 50 | */ |
|
| 51 | public function activity() |
|
| 52 | { |
|
| 53 | return $this |
|
| 54 | ->hasOne('Tinyissue\Model\User\Activity', 'action_id') |
|
| 55 | ->where('type_id', '=', Model\Activity::TYPE_NOTE); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Note can have many messages queue. |
|
| 60 | * |
|
| 61 | * @return Relations\HasMany |
|
| 62 | */ |
|
| 63 | public function messagesQueue() |
|
| 64 | { |
|
| 65 | return $this->morphMany('Tinyissue\Model\Message\Queue', 'model'); |
|
| 66 | } |
|
| 67 | ||
| 68 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
|
| 69 | abstract public function hasOne($related, $foreignKey = null, $localKey = null); |
|
| 70 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
| 71 | } |
|
| 72 | ||