syamsoul / laravel-action-delay
Delay a Job, Database Query or PHP code at a specific datetime easily with one simple command.
Installs: 149
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
Type:laravel-package
Requires
- php: >=8.0.0
- haydenpierce/class-finder: ^0.5.3
- illuminate/bus: ^10.0|^11.0|^12.0
- illuminate/console: ^10.0|^11.0|^12.0
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/queue: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
README
Introduction
This package allows you to delay an action (Jobs, Database Query, PHP Code or External Process) at specific datetime with a simple command.
Requirement
- Laravel 10.x (and above)
Installation
This package can be used in Laravel 10.x or higher. If you are using an older version of Laravel, there's might be some problem. If there's any problem, you can create new issue and I will fix it as soon as possible.
You can install the package via composer:
composer require syamsoul/laravel-action-delay
Usage
You can delay an action via Artisan
command.
php artisan souldoit:action-delay
Single-Line Commands (No Prompts)
You can delay actions using single-line commands without any interactive prompts. This is useful for automation, scripts, or when you want to schedule actions programmatically.
1. Delay Laravel Jobs
php artisan souldoit:action-delay --action=1 --job=\\SoulDoit\\ActionDelay\\Jobs\\ExternalProcessJob --job-parameter="touch newfile.txt" --delay-at="2025-06-25 16:25:00"
2. Delay Database Query
php artisan souldoit:action-delay --action=2 --db-query="INSERT INTO \`users\` (\`username\`,\`email\`,\`first_name\`,\`last_name\`,\`created_at\`,\`updated_at\`) VALUES ('user01','user01@gmail.com','User','One',NOW(),NOW())" --delay-at="2025-06-25 15:51:25"
3. Delay PHP Code
php artisan souldoit:action-delay --action=3 --php-code="\DB::table('users')->insert(['username'=>'user02', 'email'=>'user02@gmail.com', 'first_name'=>'User', 'last_name'=>'Two', 'updated_at'=>now(), 'created_at'=>now()])" --delay-at="2025-06-25 16:32:00"
4. Delay External Process
php artisan souldoit:action-delay --action=4 --command="php artisan down" --command-timeout=600 --delay-at="2025-06-25 16:37:50"
Available Options:
--action
: Action type (1=Laravel Jobs, 2=Database Query, 3=PHP Code, 4=External Process)--job
: Job class name (for action=1)--job-parameter
: Job parameters (for action=1)--db-query
: SQL query (for action=2)--php-code
: PHP code to execute (for action=3)--command
: Command to execute (for action=4)--command-timeout
: Process timeout in seconds (for action=4, default: 600)--delay-seconds
: Delay execution by specified number of seconds from current time--delay-at
: Execution at specific date & time in UTC (format: Y-m-d H:i:s)
Interactive Prompts
1. Delay Laravel Jobs
What action you want to delay? [Laravel Jobs]: [1] Laravel Jobs [2] Database Query [3] PHP Code [4] External Process > 1 What job you want to delay? [App\Jobs\GenerateCertificate]: [1] App\Jobs\GenerateCertificate [2] App\Jobs\SendCongratulationsEmail > 2 Please insert #1 parameter: `user` (Type: App\Models\User): > \App\Models\User::find(1) Please insert #2 parameter: `text` (Type: string): > Congratulations on your success! What time to execute (in UTC time, format:Y-m-d H:i:s): > 2024-06-01 10:16:00
2. Delay Database Query
What action you want to delay? [Laravel Jobs]: [1] Laravel Jobs [2] Database Query [3] PHP Code [4] External Process > 2 Enter MySQL query: > UPDATE `variables` SET `_value`='false' WHERE `_key`='maintainance_mode_enabled' What time to execute (in UTC time, format:Y-m-d H:i:s): > 2024-06-01 08:30:35
3. Delay PHP Code
What action you want to delay? [Laravel Jobs]: [1] Laravel Jobs [2] Database Query [3] PHP Code [4] External Process > 3 Enter PHP code: > \App\Models\Variable::where('_key', 'maintainance_mode_enabled')->update(['_value' => 'false']); \App\Models\Variable::where('_key', 'new_feature_enabled')->update(['_value' => 'true']); What time to execute (in UTC time, format:Y-m-d H:i:s): > 2024-06-01 08:30:35
4. Delay External Process
What action you want to delay? [Laravel Jobs]: [1] Laravel Jobs [2] Database Query [3] PHP Code [4] External Process > 4 Enter command: > sh deploy Process timeout [600]: #default is 600 seconds, enter to choose default value > What time to execute (in UTC time, format:Y-m-d H:i:s): > 2024-06-01 08:30:35
Support me
If you find this package helps you, kindly support me by donating some BNB (BSC) to the address below.
0x364d8eA5E7a4ce97e89f7b2cb7198d6d5DFe0aCe
License
The MIT License (MIT). Please see License File for more information.