You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`HasActions` trait renammed to `HasScheduledAction`
5
+
- no more recurring support
6
+
- column names changed
7
+
-`act_on` -> `act_date`
8
+
-`act_at` -> `act_time`
9
+
-`recurring` removed
10
+
- config file renammed to `scheduled-action.php`
11
+
- action status type getter local scopes to attribute accessor - [refer c26444a](https://github.com/devsrv/laravel-scheduled-model-action/commit/c26444a86521efb742a2029ec7cd2790041b8b53)
12
+
- fluent create method `forModel` renammed to `for` - [refer](https://github.com/devsrv/laravel-scheduled-model-action/commit/3862bd057dea76e43fa22cb7258a2c1db0b72885#diff-6594cc5a0ca7713d827cf28b57232041050abce29f57255122807f5224855504R20)
13
+
14
+
- fluent create method signatures changed - for chaining needs to start with `ModelAction::for($model)->...`
15
+
## v1.1.0 - 2021-07-08
16
+
17
+
### added
18
+
- delete any scheduled action when main model is deleted
Copy file name to clipboardExpand all lines: README.md
+52-65Lines changed: 52 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@
3
3
[](https://packagist.org/packages/devsrv/laravel-inplace)
> imagine a job portal where if an application gets rejected the app needs to notify the applicant via automated email after 3 days of that event, during that period the admin may change his mind and prevent the auto mail sending or modify the mail content
11
11
12
12
For any scheduled task we can directly use Laravel's [queue](https://laravel.com/docs/8.x/queues) but what if that task needs to be modified in some way before it gets executed?
13
13
14
-
This package stores all the tasks that needs to run on a future date & time / recurringly and perform a task only before few moments when it is scheduled to run so that we get the chance to modify the task before it gets executed.
14
+
This package stores all the tasks that needs to run on a future date & time and executes each only on the day when it is scheduled to run so that we get the chance to modify the task before it gets executed.
15
15
16
16
It uses Laravel's task [scheduling](https://laravel.com/docs/8.x/scheduling) to figure out & handle the tasks that needs to be run for the current day at the specified time for that task, and sends the task payload to a [receiver class](https://github.com/devsrv/laravel-scheduled-model-action#step---3--receiver-class-gets-task-payload--passes-the-task-to-classes-based-on-task-action-for-this-example-sending-email) of your app ([configurable](https://github.com/devsrv/laravel-scheduled-model-action#step---3--receiver-class-gets-task-payload--passes-the-task-to-classes-based-on-task-action-for-this-example-sending-email)). So how to perform the task is totally up to you.
#### ✔️ Add Scheduled Task to `app/Console/Kernel.php`
49
49
```php
50
50
$schedule->command('scheduledaction:poll --tasks=10')->hourly(); // poll pending tasks (10 tasks every hour & sends payload to your receiver, customize as per your app)
51
-
52
-
$schedule->command('scheduledaction:reset')->dailyAt('12:01'); // resets previously finished recurring tasks' status that needs to run today, skip this if your app doesn't need recurring task handling
53
51
```
54
52
55
-
#### ✔️ Use the `HasActions` trait in your models
53
+
#### ✔️ Use the `HasScheduledAction` trait in your models
56
54
```php
57
-
use Devsrv\ScheduledAction\Traits\HasActions;
55
+
use Devsrv\ScheduledAction\Traits\HasScheduledAction;
58
56
59
57
class Candidate extends Model
60
58
{
61
-
use HasFactory, HasActions;
59
+
use HasFactory, HasScheduledAction;
62
60
63
61
...
64
62
}
65
63
```
66
64
67
65
### 💡 Note :
68
-
- This package creates two tables`model_actions` and `model_action_recurring`
66
+
- This package creates one table`model_actions`
69
67
- Every task has 4 satatus `PENDING``FINISHED``CANCELLED``DISPATCHED`
70
68
- The `scheduledaction:poll` artisan command polls `PENDING` tasks for the present day and passes the tasks payload to your receiver class.
71
-
- Set how often you want the poll to happen of how many tasks needs to be passed to your receiver (the above [example](#%EF%B8%8F-add-scheduled-task-to-appconsolekernelphp) shows 10 per hour)
69
+
- Set how often you want the poll to happen and how many tasks needs to be passed to your receiver (the above [example](#%EF%B8%8F-add-scheduled-task-to-appconsolekernelphp) shows 10 per hour)
72
70
-`PENDING` tasks gets run at specified date & time, remember to mark the task as `FINISHED` or `CANCELLED` based on how it was handled [check example](#step---4--email-sending-task-payload-gets-received-via-previous-receiver-class-and-mail-is-sent).
73
-
- The `scheduledaction:reset` command updates only `FINISHED` recurring tasks to `PENDING` if it needs to run today i.e. resets the recurring tasks which is basically just a query so we can run it once a day
74
71
- Most likely you'll use queue to run a task at a specified time so after dispatching to a queued job you might want to set the status as `DISPATCHED`
75
72
76
73
## There are many fluent methods to interact with the tables
$action->setActAt($carbon)->save(); // date and time will be extracted
173
166
$action->setActDate($carbon)->save(); // only date will be used
174
167
$action->setActTime($carbon)->save(); // only time will be used
175
-
176
-
$action->markAsRecurringRunsOnEvery([Days::SUNDAY, ..]); // stores only the given days removeing any existing day that was previously set as recurring day
177
-
$action->syncWithoutDetachingRunsOnEvery([Days::SUNDAY, ..]); // doesnt remove anything yet adds any new days given
0 commit comments