renatomarinho /
laravel-gitscrum
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * GitScrum v0.1. |
||
| 4 | * |
||
| 5 | * @author Renato Marinho <[email protected]> |
||
| 6 | * @license http://opensource.org/licenses/GPL-3.0 GPLv3 |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace GitScrum\Models; |
||
| 10 | |||
| 11 | use Illuminate\Database\Eloquent\Model; |
||
| 12 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
| 13 | use Carbon\Carbon; |
||
| 14 | use GitScrum\Scopes\GlobalScope; |
||
| 15 | use GitScrum\Classes\Parsedown; |
||
| 16 | |||
| 17 | class Issue extends Model |
||
| 18 | { |
||
| 19 | use SoftDeletes; |
||
| 20 | use GlobalScope; |
||
| 21 | /** |
||
| 22 | * The database table used by the model. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected $table = 'issues'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Attributes that should be mass-assignable. |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | protected $fillable = ['config_issue_effort_id', 'issue_type_id', 'provider_id', 'provider', 'user_id', 'product_backlog_id', 'parent_id', |
||
| 34 | 'branch_id', 'sprint_id', 'user_story_id', 'number', 'effort', 'slug', 'code', 'title', 'description', 'state', |
||
| 35 | 'config_status_id', 'position', 'is_planning_poker', 'closed_user_id', 'closed_at', ]; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * The attributes excluded from the model's JSON form. |
||
| 39 | * |
||
| 40 | * @var array |
||
| 41 | */ |
||
| 42 | protected $hidden = []; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * The attributes that should be casted to native types. |
||
| 46 | * |
||
| 47 | * @var array |
||
| 48 | */ |
||
| 49 | protected $casts = []; |
||
| 50 | |||
| 51 | protected $dates = ['deleted_at']; |
||
| 52 | |||
| 53 | protected static function boot() |
||
| 54 | { |
||
| 55 | parent::boot(); |
||
| 56 | } |
||
| 57 | |||
| 58 | public function branch() |
||
| 59 | { |
||
| 60 | return $this->belongsTo(\GitScrum\Models\Branch::class, 'branch_id', 'id'); |
||
| 61 | } |
||
| 62 | |||
| 63 | public function type() |
||
| 64 | { |
||
| 65 | return $this->belongsTo(\GitScrum\Models\IssueType::class, 'issue_type_id', 'id'); |
||
| 66 | } |
||
| 67 | |||
| 68 | public function configEffort() |
||
| 69 | { |
||
| 70 | return $this->belongsTo(\GitScrum\Models\ConfigIssueEffort::class, 'config_issue_effort_id', 'id'); |
||
| 71 | } |
||
| 72 | |||
| 73 | public function sprint() |
||
| 74 | { |
||
| 75 | return $this->belongsTo(\GitScrum\Models\Sprint::class, 'sprint_id', 'id'); |
||
| 76 | } |
||
| 77 | |||
| 78 | public function productBacklog() |
||
| 79 | { |
||
| 80 | return $this->belongsTo(\GitScrum\Models\ProductBacklog::class, 'product_backlog_id', 'id'); |
||
| 81 | } |
||
| 82 | |||
| 83 | public function userStory() |
||
| 84 | { |
||
| 85 | return $this->belongsTo(\GitScrum\Models\UserStory::class, 'user_story_id', 'id'); |
||
| 86 | } |
||
| 87 | |||
| 88 | public function user() |
||
| 89 | { |
||
| 90 | return $this->belongsTo(\GitScrum\Models\User::class, 'user_id', 'id'); |
||
| 91 | } |
||
| 92 | |||
| 93 | public function closedUser() |
||
| 94 | { |
||
| 95 | return $this->belongsTo(\GitScrum\Models\User::class, 'closed_user_id', 'id'); |
||
| 96 | } |
||
| 97 | |||
| 98 | public function users() |
||
| 99 | { |
||
| 100 | return $this->belongsToMany(\GitScrum\Models\User::class, 'issues_has_users', 'issue_id', 'user_id'); |
||
| 101 | } |
||
| 102 | |||
| 103 | public function commits() |
||
| 104 | { |
||
| 105 | return $this->hasMany(\GitScrum\Models\Commit::class, 'issue_id', 'id'); |
||
| 106 | } |
||
| 107 | |||
| 108 | public function comments() |
||
|
0 ignored issues
–
show
|
|||
| 109 | { |
||
| 110 | return $this->morphMany(\GitScrum\Models\Comment::class, 'commentable') |
||
| 111 | ->orderby('created_at', 'DESC'); |
||
| 112 | } |
||
| 113 | |||
| 114 | public function attachments() |
||
| 115 | { |
||
| 116 | return $this->morphMany(\GitScrum\Models\Attachment::class, 'attachmentable'); |
||
| 117 | } |
||
| 118 | |||
| 119 | public function notes() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 120 | { |
||
| 121 | return $this->morphMany(\GitScrum\Models\Note::class, 'noteable') |
||
| 122 | ->orderby('position', 'ASC'); |
||
| 123 | } |
||
| 124 | |||
| 125 | public function favorite() |
||
| 126 | { |
||
| 127 | return $this->morphOne(\GitScrum\Models\Favorite::class, 'favoriteable'); |
||
| 128 | } |
||
| 129 | |||
| 130 | public function labels() |
||
| 131 | { |
||
| 132 | return $this->morphToMany(\GitScrum\Models\Label::class, 'labelable'); |
||
| 133 | } |
||
| 134 | |||
| 135 | public function status() |
||
| 136 | { |
||
| 137 | return $this->hasOne(\GitScrum\Models\ConfigStatus::class, 'id', 'config_status_id'); |
||
| 138 | } |
||
| 139 | |||
| 140 | public function statuses() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 141 | { |
||
| 142 | return $this->morphMany(\GitScrum\Models\Status::class, 'statusesable') |
||
| 143 | ->orderby('created_at', 'DESC'); |
||
| 144 | } |
||
| 145 | |||
| 146 | public function dateForHumans($dateField = 'created_at') |
||
| 147 | { |
||
| 148 | return Carbon::createFromFormat('Y-m-d H:i:s', $this->attributes[$dateField])->diffForHumans(); |
||
| 149 | } |
||
| 150 | |||
| 151 | public function getNumberAttribute() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 152 | { |
||
| 153 | return isset($this->attributes['number']) ? $this->attributes['number'] : null; |
||
| 154 | } |
||
| 155 | |||
| 156 | public function getStatusAvailableAttribute() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 157 | { |
||
| 158 | return ConfigStatus::type('issue')->get(); |
||
| 159 | } |
||
| 160 | |||
| 161 | public function getSprintSlugAttribute() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 162 | { |
||
| 163 | return isset($this->sprint->slug) ? $this->sprint->slug : 0; |
||
|
0 ignored issues
–
show
The property
sprint does not exist on object<GitScrum\Models\Issue>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 164 | } |
||
| 165 | |||
| 166 | public function getSprintClosedAttribute() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 167 | { |
||
| 168 | return isset($this->sprint->closed_at) ? $this->sprint->closed_at : null; |
||
|
0 ignored issues
–
show
The property
sprint does not exist on object<GitScrum\Models\Issue>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 169 | } |
||
| 170 | |||
| 171 | public function getDescriptionAttribute() |
||
| 172 | { |
||
| 173 | $parsedown = new Parsedown; |
||
| 174 | return $parsedown->text($this->attributes['description']); |
||
| 175 | } |
||
| 176 | |||
| 177 | public function getMarkdownDescriptionAttribute() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 178 | { |
||
| 179 | return $this->attributes['description']; |
||
| 180 | } |
||
| 181 | } |
||
| 182 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.