Using Laravel schedule tu update seems to not update datas in 'content' folder #142
happytodev
started this conversation in
General
Replies: 2 comments 2 replies
-
to give some context, this is the part in model in charge to update : public function scopeToBePublished($query)
{
return $query->where('status', 'scheduled')->where('published_at', '<=', now());
}
public static function updatePostToBePublished()
{
self::toBePublished()
->update([
'status' => 'published',
'published_at' => now()
]);
} This is called by my service provider : $this->app->afterResolving(Schedule::class, function (Schedule $schedule) {
// $this->app->booted(function () {
// $schedule = app(Schedule::class);
$schedule->call(function () {
// Post::toBePublished()
Post::updatePostToBePublished();
// Post::where('status', 'scheduled')->where('published_at', '<=', now())
// ->update([
// 'status' => 'published',
// 'published_at' => now()
// ]);
})
->everyMinute()
->appendOutputTo(base_path('storage/logs/schedules.log'));
}); As you can see, I tried differents approaches. As I said, in my app the data displays good and in the sqlite too. But my content file stays with |
Beta Was this translation helpful? Give feedback.
2 replies
-
I found the solution : public function scopeToBePublished($query)
{
return $query->where('status', 'scheduled')->where('published_at', '<=', now())->get();
}
public static function updatePostToBePublished()
{
foreach (Post::toBePublished() as $post) {
$post->update([
'status' => 'published',
'published_at' => now()
]);
}
} If it could be helping someone later. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Ryan in Orbit it seems when I use Laravel schedule function the SQLite base are updated but not the files in content folder. Is this a bug or a misunderstanding from me ?
I can show you if you want.
See you
Beta Was this translation helpful? Give feedback.
All reactions