| @@ 149-170 (lines=22) @@ | ||
| 146 | * |
|
| 147 | * @return void |
|
| 148 | */ |
|
| 149 | public function add() |
|
| 150 | { |
|
| 151 | $data = $this->request->getParsedBody(); |
|
| 152 | if ( ! array_key_exists('id', $data)) |
|
| 153 | { |
|
| 154 | $this->redirect("anime/add", 303); |
|
| 155 | } |
|
| 156 | ||
| 157 | $result = $this->model->createLibraryItem($data); |
|
| 158 | ||
| 159 | if ($result) |
|
| 160 | { |
|
| 161 | $this->set_flash_message('Added new anime to list', 'success'); |
|
| 162 | $this->cache->clear(); |
|
| 163 | } |
|
| 164 | else |
|
| 165 | { |
|
| 166 | $this->set_flash_message('Failed to add new anime to list', 'error'); |
|
| 167 | } |
|
| 168 | ||
| 169 | $this->session_redirect(); |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * Form to edit details about a series |
|
| @@ 132-153 (lines=22) @@ | ||
| 129 | * |
|
| 130 | * @return void |
|
| 131 | */ |
|
| 132 | public function add() |
|
| 133 | { |
|
| 134 | $data = $this->request->getParsedBody(); |
|
| 135 | if ( ! array_key_exists('id', $data)) |
|
| 136 | { |
|
| 137 | $this->redirect("manga/add", 303); |
|
| 138 | } |
|
| 139 | ||
| 140 | $result = $this->model->createLibraryItem($data); |
|
| 141 | ||
| 142 | if ($result) |
|
| 143 | { |
|
| 144 | $this->set_flash_message('Added new manga to list', 'success'); |
|
| 145 | $this->cache->clear(); |
|
| 146 | } |
|
| 147 | else |
|
| 148 | { |
|
| 149 | $this->set_flash_message('Failed to add new manga to list' . $result['body'], 'error'); |
|
| 150 | } |
|
| 151 | ||
| 152 | $this->session_redirect(); |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Show the manga edit form |
|