Publish created post on a certain date

  laravel, php

Right now I have a working post create function that creates a post and sends a notification to the user that a post has been created. How do I manage this if the author of the post wants to publish the post at a certain date. Let’s say they fill in a publish_date and i want the controller to create the post on that publish_date. Right now it just creates the post and send notification instantly.

public function create()
  $post = Post::create([
     'publish_date'=> $request->publish_date
  User::get()->each->notify(new PostCreated($post)); //sends notification to user using queue and redis

Source: Laravel

Leave a Reply