Skip to content

Commit

Permalink
apiBlog
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoelias123 committed Jun 4, 2019
1 parent e1aec96 commit 889dd8b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/lang/pt-BR/blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'tags' => 'Tag',
'topics' => 'Tópicos',
'stats' => 'Estatísticas',
'login' => 'assinar em',
'login' => 'Logar',
'logout' => 'Sair',
],
],
Expand Down
13 changes: 13 additions & 0 deletions stubs/controllers/BlogController.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ use Canvas\Events\PostViewed;

class BlogController extends Controller
{
/**
* Show the posts per page in JSON format
*/
public function ApiPost(){
return Post::select('id', 'title', 'summary', 'featured_image', 'published_at')->orderBy('published_at', 'desc')->paginate(3);
}

/**
* Show a single post in JSON format
*/
public function ApiPostId(Post $id){
return Post::find($id);
}
/**
* Show the blog homepage with a paginated list of results.
*
Expand Down
14 changes: 13 additions & 1 deletion stubs/routes.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ Route::prefix('blog')->group(function () {
Route::middleware('Canvas\Http\Middleware\ViewThrottle')->get('{slug}', 'BlogController@post')->name('blog.post');
Route::get('tag/{slug}', 'BlogController@tag')->name('blog.tag');
Route::get('topic/{slug}', 'BlogController@topic')->name('blog.topic');
});

/*
//Blog API
Route::prefix('api')->group(function () {
Route::middleware('throttle:500,1')->get('/', function () {
return response()->json(['message' => 'Blog API', 'status' => 'Connected']);
});
Route::get('post', 'BlogController@ApiPost');
Route::get('postId/{id}', 'BlogController@ApiPostId');
});
*/

});

1 comment on commit 889dd8b

@albertoelias123
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@austintoddj
cnvs#500

Please sign in to comment.