在laravel 5中选定日期前一天发出通知

i am working on laravel dates and i want laravel to give notification a day before or the same selected day in database how can i do that here is a part of my code : here is my controller i save remember_date in phonebook model

public function index()
{

    $current_time = Verta::now();
    $phonebooks = Phonebook::with('client')->get();
    return view('admin.phonebooks.index', compact('phonebooks'))->with('current_time',$current_time);
}

and here is the migration of my phonebooks table

 public function up()
{
    Schema::create('phonebooks', function (Blueprint $table) {
        $table->increments('id');
        $table->text('title');
        $table->longText('description');
        $table->integer('client_id');
        $table->dateTime('calldate');
        $table->dateTime('rememberdate');
        $table->timestamps();
    });
}

now i want to give notification to call the client 1 day before or the day which is stored in rememberdate .

In case: If you just want static notification section on you page
If you just wanna show something on the page as notification then just fetch data based on your condition that matches with the notification rule.

Steps:

  • Get current date (php current date)
  • Calculated date: Add a day to the current date (current date+1 day)
  • fetch record by matching the Calculated date with the rememberdate in DB
  • display your notification if any record found in DB, if record not found then "No notification found"

For date operations you can use core php and add one day to current date. But I would recommend you to use Carbon lib in laravel.

Examples using Carbon to add days in current date time Link

Update based on your comment:
I am sorry, actually I dont understand that calendar (jalali calendar) but simply adding one day will work for any calendar. First explore Carbon if that support your calendar. But I had similar problem in past. Nepal got its own dates and calendar system and I had to develop an application. What I did is I did all the operations/calculations and storing data in DB in standard time (English date-time) that servers and mysql default and then on application only at the time of displaying data, I display date-time in local format (Nepal's Local Calendar).

At the time of displaying data on web page (UI), I used date converter class that I had written to convert date-time from Nepal date-time to English date-time and vise versa.

you can use Carbon which gives you a lot of functionality working with date and Time

$currentTime = Carbon::now();
$clientsToNotif = Phonebook::with('client')->whereDate('rememberdate' , $currentTime->addDays(1))->get();

you can do any kind of notification to users now