This commit is contained in:
2020-08-11 20:21:58 +05:00
parent 1e9728f6fb
commit 7d128833ec
2 changed files with 4 additions and 4 deletions

View File

@@ -47,13 +47,13 @@ class ScrapeMihaaruCommand extends Command
foreach ($articles as $article) {
// Attach the relationship between source and article and return the curren article instance
$articleModel = $source->articles()->firstOrCreate([
$articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]],
[
"title" => $article["title"],
"url" => $article["url"],
"author" => $article["author"],
"featured_image" => $article["image"],
"body" => $article["content"],
"guid" => $article["guid"],
"published_date" => $article["date"],
"meta" => [
"title" => $article["og_title"]

View File

@@ -25,11 +25,11 @@ class SourcesController extends Controller
* @param mixed $source
* @return JsonResponse
*/
public function show(Source $source) : JsonResponse
public function show(Source $source)
{
return response()->json([
'source' => new SourceResource($source),
'articles' => ArticleResource::collection($source->articles()->paginate(8))
'articles' => ArticleResource::collection($source->articles()->latest("published_date")->paginate(8))
]);
}
}