Set notification time and notify user after that time in laravel - php

this is my first question. Currently i am working on a library management system where a user can issue a book for a certain time. when the time is over the system will notify the user and the admin. The notification will be showed in the notification bar. I have a hard time figuring out how to do that in laravel. I am trying to do the notification part using laravel pusher.

You can use delay() and set a time to notify.
$when = now()->addMinutes(10);
$user->notify((new InvoicePaid($invoice))->delay($when));

Related

Update expiration time of a google push notification channel

I am currently developing a web API where I need to listen for Google Calendar updates. I have therefor implemented the google push notifications for PHP following the documentation and everything works fine (Receiving notifications).
The problem I have is that I would like to update the channel expiration time so I don't have to create a new one every time. That is a waste of GPU and API requests, because as the documentation indicates, every time you create a new channel you start with a full initial sync (Synchronize Resources Efficiently) .
Instead, I would like to always make incremental synchronization. Any ideas on how to update the "expiration" field ?
Answer:
You cannot update the channel expiration time, you have to create a new one.
Reference:
From the link you provided, Renewing notification channels:
Currently there is no automatic way to renew a notification channel. When a channel is close to its expiration, you must create a new one by calling the watch method.
Related:
Provide a mechanism to renew activities.watch instead of erroring on non-unique channels

schedule notification in laravel 5.3

I'm having problem to schedule notifications,
I have some notifications in laravel 5.3, the notifications are being queued using the ShouldQueue interface and and Queueable trait.
The problem is I want to send the notification between specific hours, the only option built in the notification feature is using the delay method.
How can i make custom schedule for the notifications that are being queued?
You should use Laravel Sheduling for this. This will allow you to run certain code at specific moments, just like a cronjob. You can create your notifications in a scheduled task.
figured it out,
I`m calculating the current time in my server according to the target time in another time zone i want the notification to be fired using Carbon library.
after i have the target time that i want the notification to be fired i`m just adding delay to the notification with the carbon instance.

Running background process in LAMP stack

I have an application running on LAMP stack.In USER model
after expiration of subscription deadline,I need to set user's current
subscription to default or free subscription.
So I need a background process which always checks for the expiration of user's subscription deadline and set to default subscription.
Is there any other efficient and manageable solution to run a background process which will update user's data ?
Application Environment:
CakePHP,Redis,MariaDB
Please edit if this question isn't good enough to describe my problem :(
So in general your question about recurring event,
if this event do changes in DB and also another actions like send emails or stop some services or connect to remote resource,, you have to use cron job
but if this event only related to DB then you can create recurring event like the following link
In case of PHP there is not so many out-of-the-box solutions. One of the available is rabbitmq-delayed-sample. It is built on top of rabbitmq messaging system.
Usage example:
$container->get('delayed_producer')->delayedPublish(5000, $messageBody, '');
where 5000 is an expiration period after that job will be executed. You can put such code to the new user creation place.

Best option to send email notification in advance for account expiration

I am working on a e-commerce kind of application which allows user to login register and also create a deal for him.
Every deal of the user has a expiry date attached to it.Now I store all the values in the DB table against the created deal.
I want to send the user a notification couple of days before his deal expires if he has not
updated it.Now can I achieve it using the DB trigger in any way(write a script and return value from the DB trigger) as suggested in this thread.
I should run a cron job to check it for some time interval and send notification?
I am not sure FB or other sites do it for birthday reminders or other notification.Any details on the same would be helpful to go ahead.
Thank you

Google Calendar sync with php in 2 ways

I am creating a php website that uses the Google Calendar API. It's working fine with Create, Update and Delete: any event from the PHP website goes into my Google Calendar events after login.
Events created on my site are created in Google Calendar.
What I want now that is: when I create an event from my test page it goes into Google Calendar after login, then if I update or delete that event from Google Calendar then it should automatically update or delete the php website event.
Basically: 1-way sync is working fine but now I want 2-way synchronization.
If anybody has any ideas then kindly share with me, it will be much appreciated.
There are no application hooks in Google Calendar (gCal) that allow you to trigger an action when an event is deleted. Instead you must either poll gCal at intervals (this could be a cron job every few minutes/hours) and update your calendar accordingly, or any time you perform an action from your calendar have a 1 in X possibly of a full re-sync.
This implies that you are using the gCal as the definitive source, and mirroring those changes back to your local application.
well, after following these answers and building a hole 2 way sync process,
i realized there's a push notifications for calendar since 2013.
you will still need a full sync process because the push notification only notifies about a change but no data about the change.
hope it will save you some time.
Push Notifications
Would it not be an option for your system to generate an iCal output at a special, user-specific URL, and then have the user subscribe to that calendar in Google Calendars (or their iCal-reading calendar of choice)?
That way, your system would always hold the authorative calendar, and Google Calendar would reflect any changes you make automatically.
Alternately, if you are wanting changes in the Google Calendar to be reflected in your application, then you may be able to subscribe to iCals for the User's Calendar, and then poll them at a regular interval to reflect any changes the User has made at that end.
I would lean towards the first option (your iCal subscribed through Google Calendar), as it is a simpler and easier solution.

Categories