API changes

This commit is contained in:
2020-08-22 12:50:50 +05:00
parent 2c319c3305
commit 0ca2d776d5
6 changed files with 15 additions and 11 deletions

View File

@@ -16,8 +16,10 @@ final class RecentArticles extends Controller
*/ */
public function __invoke() public function __invoke()
{ {
return Article::with('source', 'topics') return [
->latest("published_date") "articles" => Article::with('source', 'topics')
->paginate(20); ->latest("published_date")
->paginate(20)
];
} }
} }

View File

@@ -26,13 +26,12 @@ class TopicsAPIController extends Controller
* Load all the articles for a given topics * Load all the articles for a given topics
* *
* @param mixed $topic * @param mixed $topic
* @return JsonResponse
*/ */
public function show(Topic $topic) : JsonResponse public function show(Topic $topic)
{ {
return response()->json([ return [
'topic' => new TopicResource($topic), 'topic' => new TopicResource($topic),
'articles' => ArticleResource::collection($topic->articles()->paginate(8)) 'articles' => $topic->articles()->paginate(8)
]); ];
} }
} }

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{ {
"/js/app.js": "/js/app.js?id=f11fe4d9c19ff901ee13", "/js/app.js": "/js/app.js?id=09b46e62c208db633001",
"/css/app.css": "/css/app.css?id=772ee94750ef3193cc32", "/css/app.css": "/css/app.css?id=772ee94750ef3193cc32",
"/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e", "/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e",
"/js/vendor.js": "/js/vendor.js?id=968f85387c9bab0e92d2" "/js/vendor.js": "/js/vendor.js?id=968f85387c9bab0e92d2"

View File

@@ -84,7 +84,7 @@ export default {
axios axios
.get("api/recent") .get("api/recent")
.then(response => { .then(response => {
this.recentStories = response.data.data; this.recentStories = response.data.articles.data;
}) })
.catch(error => { .catch(error => {
console.log(error); console.log(error);

View File

@@ -23,6 +23,7 @@
<p <p
class="ml-1 mb-4 text-gray-600 text-right MvTyper" class="ml-1 mb-4 text-gray-600 text-right MvTyper"
style="direction:rtl;" style="direction:rtl;"
v-if="article.body"
> >
{{ article.body[0].slice(0,200) }}... {{ article.body[0].slice(0,200) }}...
</p> </p>
@@ -33,6 +34,7 @@
<div> <div>
<a <a
:href="'/source/' + article.source.slug" :href="'/source/' + article.source.slug"
v-if="article.source"
class="hover:underline" class="hover:underline"
> >
<p <p
@@ -44,6 +46,7 @@
<img <img
:src="article.source.logo" :src="article.source.logo"
v-if="article.source"
class="h-10 w-10 rounded-full ml-1 object-cover" class="h-10 w-10 rounded-full ml-1 object-cover"
/> />
</div> </div>