1 | <?php |
||
40 | class Issue extends Model implements HasPresenter |
||
41 | { |
||
42 | use SoftDeletes, ValidatingTrait; |
||
43 | |||
44 | /** |
||
45 | * The accessors to append to the model's serialized form. |
||
46 | * |
||
47 | * @var string[] |
||
48 | */ |
||
49 | protected $appends = ['human_status']; |
||
50 | |||
51 | /** |
||
52 | * The attributes that should be casted to native types. |
||
53 | * |
||
54 | * @var string[] |
||
55 | */ |
||
56 | protected $casts = [ |
||
57 | 'id' => 'int', |
||
58 | 'deleted_at' => 'date', |
||
59 | ]; |
||
60 | |||
61 | /** |
||
62 | * The fillable properties. |
||
63 | * |
||
64 | * @var string[] |
||
65 | */ |
||
66 | protected $fillable = [ |
||
67 | 'author_id', |
||
68 | 'project_id', |
||
69 | 'title', |
||
70 | 'description', |
||
71 | 'created_at', |
||
72 | 'updated_at', |
||
73 | ]; |
||
74 | |||
75 | /** |
||
76 | * The validation rules. |
||
77 | * |
||
78 | * @var string[] |
||
79 | */ |
||
80 | public $rules = [ |
||
81 | 'author_id' => 'int', |
||
82 | 'project_id' => 'int', |
||
83 | 'title' => 'required', |
||
84 | 'description' => 'required', |
||
85 | ]; |
||
86 | |||
87 | /** |
||
88 | * Finds all visible issues. |
||
89 | * |
||
90 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
91 | * |
||
92 | * @return \Illuminate\Database\Eloquent\Builder |
||
93 | */ |
||
94 | public function scopeVisible($query) |
||
95 | { |
||
96 | return $query->where('state', null); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * An issue belongs to a project. |
||
101 | * |
||
102 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
103 | */ |
||
104 | public function project() |
||
105 | { |
||
106 | return $this->belongsTo(Project::class, 'project_id', 'id'); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * An issue belongs to an author. |
||
111 | * |
||
112 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
113 | */ |
||
114 | public function author() |
||
118 | |||
119 | /** |
||
120 | * Returns all comments of the issue. |
||
121 | * |
||
122 | * @return \Gitamin\Models\Comment[] |
||
123 | */ |
||
124 | public function comments() |
||
128 | |||
129 | /** |
||
130 | * Returns a human readable version of the status. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getHumanStatusAttribute() |
||
135 | { |
||
136 | $statuses = trans('gitamin.issues.status'); |
||
137 | |||
138 | return $statuses[rand(0, 2)]; |
||
139 | //return $statuses[$this->state]; |
||
140 | } |
||
141 | |||
142 | public function getUrlAttribute() |
||
146 | |||
147 | /** |
||
148 | * Get the presenter class. |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getPresenterClass() |
||
156 | } |
||
157 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.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.