1 | <?php |
||
36 | class Attachment extends BaseModel |
||
37 | { |
||
38 | use CrudTrait, |
||
39 | RelationTrait; |
||
40 | |||
41 | /** |
||
42 | * Timestamp enabled. |
||
43 | * |
||
44 | * @var bool |
||
45 | */ |
||
46 | public $timestamps = true; |
||
47 | |||
48 | /** |
||
49 | * Name of database table. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $table = 'projects_issues_attachments'; |
||
54 | |||
55 | /** |
||
56 | * List of allowed columns to be used in $this->fill(). |
||
57 | * |
||
58 | * @var array |
||
59 | */ |
||
60 | protected $fillable = [ |
||
61 | 'uploaded_by', |
||
62 | 'filename', |
||
63 | 'fileextension', |
||
64 | 'filesize', |
||
65 | 'upload_token', |
||
66 | ]; |
||
67 | |||
68 | /** |
||
69 | * Whether or not the file extension is supported image type. |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | public function isImage() |
||
86 | |||
87 | /** |
||
88 | * Url to attachment download. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function download() |
||
96 | |||
97 | /** |
||
98 | * Url to display attachment. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function display() |
||
106 | |||
107 | /** |
||
108 | * Generate a URL to delete attachment. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function toDelete() |
||
116 | |||
117 | /** |
||
118 | * Whether a user can edit the attachment. |
||
119 | * |
||
120 | * @param User $user |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | public function canEdit(User $user) |
||
128 | } |
||
129 |