Bug fix
This commit is contained in:
@@ -48,29 +48,30 @@ class ScrapeSunCommand 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(
|
||||||
"title" => $article["title"],
|
["guid" => $article["guid"]],
|
||||||
"url" => $article["url"],
|
[
|
||||||
"author" => $article["author"],
|
"title" => $article["title"],
|
||||||
"featured_image" => $article["image"],
|
"url" => $article["url"],
|
||||||
"body" => $article["content"],
|
"author" => $article["author"],
|
||||||
"guid" => $article["guid"],
|
"featured_image" => $article["image"],
|
||||||
"published_date" => Carbon::parse($article["date"])->format("Y-m-d H:i:s"),
|
"body" => $article["content"],
|
||||||
"meta" => [
|
"published_date" => Carbon::parse($article["date"])->format("Y-m-d H:i:s"),
|
||||||
"title" => $article["og_title"]
|
"meta" => [
|
||||||
|
"title" => $article["og_title"]
|
||||||
|
]
|
||||||
|
|
||||||
]
|
]
|
||||||
|
);
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
collect($article["topics"])->each(function($topic) use ($articleModel) {
|
collect($article["topics"])->each(function ($topic) use ($articleModel) {
|
||||||
|
|
||||||
$topicModel = Topic::firstOrCreate(["slug" => $topic["slug"]],["name" => $topic["name"]]);
|
$topicModel = Topic::firstOrCreate(["slug" => $topic["slug"]], ["name" => $topic["name"]]);
|
||||||
|
|
||||||
$topicModel->articles()->syncWithoutDetaching($articleModel);
|
$topicModel->articles()->syncWithoutDetaching($articleModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,22 +48,24 @@ class ScrapeThiladhunCommand 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(
|
||||||
"title" => $article["title"],
|
["guid" => $article["guid"]],
|
||||||
"url" => $article["url"],
|
[
|
||||||
"author" => $article["author"],
|
"title" => $article["title"],
|
||||||
"featured_image" => $article["image"],
|
"url" => $article["url"],
|
||||||
"body" => $article["content"],
|
"author" => $article["author"],
|
||||||
"guid" => $article["guid"],
|
"featured_image" => $article["image"],
|
||||||
"published_date" => Carbon::parse($article["date"])->format("Y-m-d H:i:s"),
|
"body" => $article["content"],
|
||||||
"meta" => [
|
"published_date" => Carbon::parse($article["date"])->format("Y-m-d H:i:s"),
|
||||||
"title" => $article["og_title"]
|
"meta" => [
|
||||||
]
|
"title" => $article["og_title"]
|
||||||
|
]
|
||||||
|
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
collect($article["topics"])->each(function ($topic) use ($articleModel) {
|
collect($article["topics"])->each(function ($topic) use ($articleModel) {
|
||||||
$topicModel = Topic::firstOrCreate(["slug" => $topic["slug"]],["name" => $topic["name"]]);
|
$topicModel = Topic::firstOrCreate(["slug" => $topic["slug"]], ["name" => $topic["name"]]);
|
||||||
|
|
||||||
$topicModel->articles()->syncWithoutDetaching($articleModel);
|
$topicModel->articles()->syncWithoutDetaching($articleModel);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user