duan2477 2018-06-06 20:12
浏览 510
已采纳

在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 .

  • 写回答

2条回答 默认 最新

  • doubi2145 2018-06-06 20:24
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)