@@ -10,21 +10,21 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Store instance of database connection used. |
| 13 | - * @var [type] |
|
| 14 | - */ |
|
| 13 | + * @var [type] |
|
| 14 | + */ |
|
| 15 | 15 | protected $databaseConnection; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * The id of the model. |
| 19 | 19 | * |
| 20 | 20 | * @property string $id |
| 21 | - */ |
|
| 21 | + */ |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Create a model instance. |
| 25 | 25 | * |
| 26 | 26 | */ |
| 27 | - public function __construct() |
|
| 27 | + public function __construct() |
|
| 28 | 28 | { |
| 29 | 29 | $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection; |
| 30 | 30 | |
@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Sets into $properties the $key => $value pairs |
| 34 | 34 | * |
| 35 | - * @param string $key |
|
| 36 | - * @param string $val |
|
| 37 | - * |
|
| 38 | - */ |
|
| 35 | + * @param string $key |
|
| 36 | + * @param string $val |
|
| 37 | + * |
|
| 38 | + */ |
|
| 39 | 39 | public function __set($key, $val) |
| 40 | 40 | { |
| 41 | 41 | $this->properties[$key] = $val; |
| 42 | 42 | } |
| 43 | 43 | /** |
| 44 | - * @param string $key |
|
| 45 | - * |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 44 | + * @param string $key |
|
| 45 | + * |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | 48 | public function __get($key) |
| 49 | 49 | { |
| 50 | 50 | return $this->properties[$key]; |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - public function getProperties() |
|
| 58 | - { |
|
| 59 | - return $this->properties; |
|
| 60 | - } |
|
| 57 | + public function getProperties() |
|
| 58 | + { |
|
| 59 | + return $this->properties; |
|
| 60 | + } |
|
| 61 | 61 | /** |
| 62 | - * Gets the name of the child class with a 's'. |
|
| 63 | - * |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 62 | + * Gets the name of the child class with a 's'. |
|
| 63 | + * |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | 66 | public function getTableName() |
| 67 | 67 | { |
| 68 | 68 | $className = explode('\\', get_called_class()); |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | return $table; |
| 71 | 71 | } |
| 72 | 72 | /** |
| 73 | - * Find the particular model with the passed id. |
|
| 74 | - * |
|
| 75 | - * @param int $id |
|
| 76 | - * |
|
| 77 | - * @return object |
|
| 78 | - */ |
|
| 73 | + * Find the particular model with the passed id. |
|
| 74 | + * |
|
| 75 | + * @param int $id |
|
| 76 | + * |
|
| 77 | + * @return object |
|
| 78 | + */ |
|
| 79 | 79 | public static function find($id) |
| 80 | 80 | { |
| 81 | 81 | $model = new static; |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * Get the particular model with the passed id. |
|
| 87 | - * |
|
| 88 | - * @param int $id |
|
| 89 | - * |
|
| 90 | - * @return object |
|
| 91 | - */ |
|
| 86 | + * Get the particular model with the passed id. |
|
| 87 | + * |
|
| 88 | + * @param int $id |
|
| 89 | + * |
|
| 90 | + * @return object |
|
| 91 | + */ |
|
| 92 | 92 | public function get($id) |
| 93 | 93 | { |
| 94 | 94 | $sql = "SELECT * FROM {$this->getTableName()} WHERE id={$id}"; |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * Get all the models from the database. |
|
| 106 | - * |
|
| 107 | - * @return array |
|
| 108 | - */ |
|
| 105 | + * Get all the models from the database. |
|
| 106 | + * |
|
| 107 | + * @return array |
|
| 108 | + */ |
|
| 109 | 109 | public static function getAll() |
| 110 | 110 | { |
| 111 | 111 | $model = new static; |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * Returns all the models from the database. |
|
| 117 | - * |
|
| 118 | - * @return array |
|
| 119 | - */ |
|
| 116 | + * Returns all the models from the database. |
|
| 117 | + * |
|
| 118 | + * @return array |
|
| 119 | + */ |
|
| 120 | 120 | public function all() |
| 121 | 121 | { |
| 122 | 122 | $sql = "SELECT * FROM {$this->getTableName()}"; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * Update the model in the database. |
| 131 | 131 | * |
| 132 | 132 | * @return int |
| 133 | - */ |
|
| 133 | + */ |
|
| 134 | 134 | private function update() |
| 135 | 135 | { |
| 136 | 136 | |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | - * Insert the model values into the database. |
|
| 155 | - * |
|
| 156 | - * @return int |
|
| 157 | - */ |
|
| 154 | + * Insert the model values into the database. |
|
| 155 | + * |
|
| 156 | + * @return int |
|
| 157 | + */ |
|
| 158 | 158 | private function create() |
| 159 | 159 | { |
| 160 | 160 | |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | return $this->id ? $this->update() : $this->create(); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Delete a model from the database. |
|
| 194 | - * @param int $id |
|
| 195 | - * @return boolean |
|
| 196 | - */ |
|
| 192 | + /** |
|
| 193 | + * Delete a model from the database. |
|
| 194 | + * @param int $id |
|
| 195 | + * @return boolean |
|
| 196 | + */ |
|
| 197 | 197 | public static function destroy($id) |
| 198 | 198 | { |
| 199 | 199 | $model = new static; |