|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Storgman - Student Organizations Management |
|
5
|
|
|
* Copyright (C) 2014-2016, Dejan Angelov <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This file is part of Storgman. |
|
8
|
|
|
* |
|
9
|
|
|
* Storgman is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by |
|
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
12
|
|
|
* (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* Storgman is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with Storgman. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
* @package Storgman |
|
23
|
|
|
* @copyright Copyright (C) 2014-2016, Dejan Angelov <[email protected]> |
|
24
|
|
|
* @license https://github.com/angelov/storgman/blob/master/LICENSE |
|
25
|
|
|
* @author Dejan Angelov <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
namespace Angelov\Storgman\Meetings\Attachments; |
|
29
|
|
|
|
|
30
|
|
|
use Angelov\Storgman\Meetings\Meeting; |
|
31
|
|
|
use Angelov\Storgman\Members\Member; |
|
32
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
33
|
|
|
|
|
34
|
|
|
class Attachment extends Model |
|
35
|
|
|
{ |
|
36
|
|
|
protected $table = "meeting_attachments"; |
|
37
|
|
|
|
|
38
|
|
|
public function getId() |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->getAttribute('id'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getFilename() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->getAttribute('filename'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function setFilename($filename) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->setAttribute("filename", $filename); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getStorageFilename() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->getAttribute('storage_filename'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function setStorageFilename($filename) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->setAttribute('storage_filename', $filename); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getSize() |
|
64
|
|
|
{ |
|
65
|
|
|
$value = $this->getAttribute('size'); |
|
66
|
|
|
$size = new FileSize($value, FileSize::UNIT_KILOBYTE); |
|
67
|
|
|
|
|
68
|
|
|
return $size; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function setSize($size) |
|
72
|
|
|
{ |
|
73
|
|
|
$this->setAttribute('size', $size); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function meeting() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->belongsTo(Meeting::class, 'meeting_id'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return Meeting |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getMeeting() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->meeting; |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function setMeeting(Meeting $meeting = null) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->meeting()->associate($meeting); |
|
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function owner() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->belongsTo(Member::class, 'owner_id'); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return Member |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getOwner() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->owner; |
|
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function setOwner(Member $owner) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->owner()->associate($owner); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return \DateTime |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getCreatedAt() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->getAttribute('created_at'); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
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@propertyannotation 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.