|
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\LocalCommittees; |
|
29
|
|
|
|
|
30
|
|
|
use Angelov\Storgman\Events\Event; |
|
31
|
|
|
use Angelov\Storgman\LocalCommittees\Cities\City; |
|
32
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
33
|
|
|
|
|
34
|
|
|
class LocalCommittee extends Model |
|
35
|
|
|
{ |
|
36
|
|
|
public function getId() |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->getAttribute('id'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getTitle() |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->getAttribute('title'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function setTitle($title) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->setAttribute('title', $title); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function city() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->belongsTo(City::class, 'city_id'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function setCity(City $city) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->city()->associate($city); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return City |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getCity() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->city; |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function events() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->hasMany(Event::class, 'host_id'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return Event[] |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getEvents() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->events->all(); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
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.