bug fix
This commit is contained in:
@@ -47,13 +47,13 @@ class ScrapeMihaaruCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
"author" => $article["author"],
|
"author" => $article["author"],
|
||||||
"featured_image" => $article["image"],
|
"featured_image" => $article["image"],
|
||||||
"body" => $article["content"],
|
"body" => $article["content"],
|
||||||
"guid" => $article["guid"],
|
|
||||||
"published_date" => $article["date"],
|
"published_date" => $article["date"],
|
||||||
"meta" => [
|
"meta" => [
|
||||||
"title" => $article["og_title"]
|
"title" => $article["og_title"]
|
||||||
|
@@ -25,11 +25,11 @@ class SourcesController extends Controller
|
|||||||
* @param mixed $source
|
* @param mixed $source
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function show(Source $source) : JsonResponse
|
public function show(Source $source)
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'source' => new SourceResource($source),
|
'source' => new SourceResource($source),
|
||||||
'articles' => ArticleResource::collection($source->articles()->paginate(8))
|
'articles' => ArticleResource::collection($source->articles()->latest("published_date")->paginate(8))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user