@@ 257-281 (lines=25) @@ | ||
254 | * @param int $id |
|
255 | * @return Redirect |
|
256 | */ |
|
257 | public function getDelete($id = null) |
|
258 | { |
|
259 | // Get post information |
|
260 | $post = Blog::getPostsRepository()->find($id); |
|
261 | ||
262 | if ($post == null) |
|
263 | { |
|
264 | // Prepare the error message |
|
265 | $error = Lang::get('blog.posts.not_found'); |
|
266 | ||
267 | // Redirect to the post management page |
|
268 | return Redirect::route('posts')->with('error', $error); |
|
269 | } |
|
270 | ||
271 | Base::Log('Post (' . $post->id . ') was deleted.'); |
|
272 | ||
273 | // Delete the post |
|
274 | $post->delete(); |
|
275 | ||
276 | // Prepare the success message |
|
277 | $success = Lang::get('blog.posts.deleted'); |
|
278 | ||
279 | // Redirect to the post management page |
|
280 | return Redirect::route('posts')->with('success', $success); |
|
281 | } |
|
282 | ||
283 | /** |
|
284 | * Show a list of all the deleted posts. |
|
@@ 303-327 (lines=25) @@ | ||
300 | * @param int $id |
|
301 | * @return Redirect |
|
302 | */ |
|
303 | public function getRestore($id = null) |
|
304 | { |
|
305 | // Get post information |
|
306 | $post = Blog::getPostsRepository()->withTrashed()->find($id); |
|
307 | ||
308 | if ($post == null) |
|
309 | { |
|
310 | // Prepare the error message |
|
311 | $error = Lang::get('blog.posts.not_found'); |
|
312 | ||
313 | // Redirect to the post management page |
|
314 | return Redirect::route('post.deleted')->with('error', $error); |
|
315 | } |
|
316 | ||
317 | Base::Log('Post (' . $post->id . ') was restored.'); |
|
318 | ||
319 | // Restore the post |
|
320 | $post->restore(); |
|
321 | ||
322 | // Prepare the success message |
|
323 | $success = Lang::get('blog.posts.restored'); |
|
324 | ||
325 | // Redirect to the post management page |
|
326 | return Redirect::route('posts.deleted')->with('success', $success); |
|
327 | } |
|
328 | ||
329 | } |
|
330 |