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 <renato.marinho> |
||
| 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 GitScrum\Scopes\GlobalScope; |
||
| 14 | |||
| 15 | class UserStory extends Model |
||
| 16 | { |
||
| 17 | use SoftDeletes; |
||
| 18 | use GlobalScope; |
||
| 19 | /** |
||
| 20 | * The database table used by the model. |
||
| 21 | * |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $table = 'user_stories'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Attributes that should be mass-assignable. |
||
| 28 | * |
||
| 29 | * @var array |
||
| 30 | */ |
||
| 31 | protected $fillable = ['user_id', 'product_backlog_id', 'title', 'description', 'config_priority_id', 'acceptance_criteria']; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The attributes excluded from the model's JSON form. |
||
| 35 | * |
||
| 36 | * @var array |
||
| 37 | */ |
||
| 38 | protected $hidden = []; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * The attributes that should be casted to native types. |
||
| 42 | * |
||
| 43 | * @var array |
||
| 44 | */ |
||
| 45 | protected $casts = []; |
||
| 46 | |||
| 47 | protected static function boot() |
||
| 48 | { |
||
| 49 | parent::boot(); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function productBacklog() |
||
| 53 | { |
||
| 54 | return $this->belongsTo(\GitScrum\Models\ProductBacklog::class, 'product_backlog_id', 'id'); |
||
| 55 | } |
||
| 56 | |||
| 57 | public function issues() |
||
|
0 ignored issues
–
show
|
|||
| 58 | { |
||
| 59 | return $this->hasMany(\GitScrum\Models\Issue::class, 'user_story_id', 'id') |
||
| 60 | ->orderby('position', 'ASC'); |
||
| 61 | } |
||
| 62 | |||
| 63 | public function priority() |
||
| 64 | { |
||
| 65 | return $this->hasOne(\GitScrum\Models\ConfigPriority::class, 'id', 'config_priority_id'); |
||
| 66 | } |
||
| 67 | |||
| 68 | public function favorite() |
||
| 69 | { |
||
| 70 | return $this->morphOne(\GitScrum\Models\Favorite::class, 'favoriteable'); |
||
| 71 | } |
||
| 72 | |||
| 73 | public function comments() |
||
|
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...
|
|||
| 74 | { |
||
| 75 | return $this->morphMany(\GitScrum\Models\Comment::class, 'commentable') |
||
| 76 | ->orderby('created_at', 'DESC'); |
||
| 77 | } |
||
| 78 | |||
| 79 | 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...
|
|||
| 80 | { |
||
| 81 | return $this->morphMany(\GitScrum\Models\Note::class, 'noteable') |
||
| 82 | ->orderby('position', 'ASC'); |
||
| 83 | } |
||
| 84 | |||
| 85 | public function labels() |
||
| 86 | { |
||
| 87 | return $this->morphToMany(\GitScrum\Models\Label::class, 'labelable'); |
||
| 88 | } |
||
| 89 | |||
| 90 | public function activities() |
||
|
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...
|
|||
| 91 | { |
||
| 92 | $activities = $this->issues() |
||
| 93 | ->with('statuses')->get()->map(function ($issue) { |
||
| 94 | return $issue->statuses; |
||
| 95 | })->flatten(1)->map(function ($statuses) { |
||
| 96 | return $statuses; |
||
| 97 | })->sortByDesc('created_at'); |
||
| 98 | |||
| 99 | $activities->splice(15); |
||
| 100 | |||
| 101 | return $activities->all(); |
||
| 102 | } |
||
| 103 | |||
| 104 | public function issuesHasUsers($total = 3) |
||
|
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...
|
|||
| 105 | { |
||
| 106 | $users = $this->issues->map(function ($issue) { |
||
|
0 ignored issues
–
show
The property
issues does not exist on object<GitScrum\Models\UserStory>. 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...
|
|||
| 107 | return $issue->users; |
||
| 108 | })->reject(function ($value) { |
||
| 109 | return $value == null; |
||
| 110 | })->flatten(1)->unique('id')->splice(0, $total); |
||
| 111 | |||
| 112 | return $users->all(); |
||
| 113 | } |
||
| 114 | |||
| 115 | public function issueStatus() |
||
|
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...
|
|||
| 116 | { |
||
| 117 | $status = $this->issues->map(function ($issue) { |
||
|
0 ignored issues
–
show
The property
issues does not exist on object<GitScrum\Models\UserStory>. 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...
|
|||
| 118 | return $issue->status; |
||
| 119 | })->groupBy('slug')->all(); |
||
| 120 | |||
| 121 | return $status; |
||
| 122 | } |
||
| 123 | } |
||
| 124 |
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.