@@ -11,11 +11,11 @@ |
||
| 11 | 11 | * @param \Closure $next |
| 12 | 12 | * @return mixed |
| 13 | 13 | */ |
| 14 | - public function handle($request, Closure $next, $controller){ |
|
| 14 | + public function handle($request, Closure $next, $controller) { |
|
| 15 | 15 | |
| 16 | 16 | $controller = new $controller(); |
| 17 | 17 | |
| 18 | - if(!$controller->isAuthorized($request)){ |
|
| 18 | + if (!$controller->isAuthorized($request)) { |
|
| 19 | 19 | return $controller->error("You aren't allowed to perform the requested action", 403); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -4,20 +4,20 @@ |
||
| 4 | 4 | |
| 5 | 5 | class CommentController extends Controller{ |
| 6 | 6 | |
| 7 | - public function index(){ |
|
| 7 | + public function index(){ |
|
| 8 | 8 | |
| 9 | - $comments = Comment::all(); |
|
| 10 | - return $this->success($comments, 200); |
|
| 11 | - } |
|
| 9 | + $comments = Comment::all(); |
|
| 10 | + return $this->success($comments, 200); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function show($id){ |
|
| 13 | + public function show($id){ |
|
| 14 | 14 | |
| 15 | - $comment = Comment::find($id); |
|
| 15 | + $comment = Comment::find($id); |
|
| 16 | 16 | |
| 17 | - if(!$comment){ |
|
| 18 | - return $this->error("The comment with {$id} doesn't exist", 404); |
|
| 19 | - } |
|
| 17 | + if(!$comment){ |
|
| 18 | + return $this->error("The comment with {$id} doesn't exist", 404); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return $this->success($comment, 200); |
|
| 22 | - } |
|
| 21 | + return $this->success($comment, 200); |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | use App\Comment; |
| 4 | 4 | |
| 5 | -class CommentController extends Controller{ |
|
| 5 | +class CommentController extends Controller { |
|
| 6 | 6 | |
| 7 | - public function index(){ |
|
| 7 | + public function index() { |
|
| 8 | 8 | |
| 9 | 9 | $comments = Comment::all(); |
| 10 | 10 | return $this->success($comments, 200); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public function show($id){ |
|
| 13 | + public function show($id) { |
|
| 14 | 14 | |
| 15 | 15 | $comment = Comment::find($id); |
| 16 | 16 | |
| 17 | - if(!$comment){ |
|
| 17 | + if (!$comment) { |
|
| 18 | 18 | return $this->error("The comment with {$id} doesn't exist", 404); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | // Home Page |
| 15 | 15 | $app->get('/', function () use ($app){ |
| 16 | - return $app->version(); |
|
| 16 | + return $app->version(); |
|
| 17 | 17 | }); |
| 18 | 18 | |
| 19 | 19 | // Posts |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Home Page |
| 15 | -$app->get('/', function () use ($app){ |
|
| 15 | +$app->get('/', function() use ($app){ |
|
| 16 | 16 | return $app->version(); |
| 17 | 17 | }); |
| 18 | 18 | |
| 19 | 19 | // Posts |
| 20 | -$app->get('/posts','PostController@index'); |
|
| 21 | -$app->post('/posts','PostController@store'); |
|
| 22 | -$app->get('/posts/{post_id}','PostController@show'); |
|
| 20 | +$app->get('/posts', 'PostController@index'); |
|
| 21 | +$app->post('/posts', 'PostController@store'); |
|
| 22 | +$app->get('/posts/{post_id}', 'PostController@show'); |
|
| 23 | 23 | $app->put('/posts/{post_id}', 'PostController@update'); |
| 24 | 24 | $app->patch('/posts/{post_id}', 'PostController@update'); |
| 25 | 25 | $app->delete('/posts/{post_id}', 'PostController@destroy'); |