1 | <?php |
||
34 | class Attachment extends BaseModel |
||
35 | { |
||
36 | use CrudTrait, |
||
37 | RelationTrait; |
||
38 | |||
39 | /** |
||
40 | * Timestamp enabled. |
||
41 | * |
||
42 | * @var bool |
||
43 | */ |
||
44 | public $timestamps = true; |
||
45 | |||
46 | /** |
||
47 | * Name of database table. |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $table = 'projects_issues_attachments'; |
||
52 | |||
53 | /** |
||
54 | * List of allowed columns to be used in $this->fill(). |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $fillable = [ |
||
59 | 'uploaded_by', |
||
60 | 'filename', |
||
61 | 'fileextension', |
||
62 | 'filesize', |
||
63 | 'upload_token', |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * Whether or not the file extension is supported image type. |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | 3 | public function isImage() |
|
72 | { |
||
73 | 3 | return in_array($this->fileextension, [ |
|
74 | 3 | 'jpg', |
|
75 | 3 | 'jpeg', |
|
76 | 3 | 'JPG', |
|
77 | 3 | 'JPEG', |
|
78 | 3 | 'png', |
|
79 | 3 | 'PNG', |
|
80 | 3 | 'gif', |
|
81 | 3 | 'GIF', |
|
82 | 3 | ]); |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Url to attachment download. |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | 3 | public function download() |
|
94 | |||
95 | /** |
||
96 | * Url to display attachment. |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function display() |
||
104 | } |
||
105 |