Skip to content

Commit 5f71f4d

Browse files
committed
Update Laravel task scheduler examples for version clarity and accuracy
1 parent c3d03fb commit 5f71f4d

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

docs/content/docs/3.framework-guides/1.laravel/2.task-scheduler.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,33 @@ services:
4949
5050
#### Example in Laravel
5151
::note
52-
This example is for Laravel version >= 11
52+
Notice the different file names betwen Laravel verisons.
5353
::
54+
::tabs
55+
56+
:::tabs-item{label="Laravel 11+"}
57+
5458
5559
```php [routes/console.php]
5660
<?php
5761

58-
use Illuminate\Support\Facades\DB;
5962
use Illuminate\Support\Facades\Schedule;
6063

61-
Schedule::call(function () {
62-
DB::table('recent_users')->delete();
63-
})->daily()->at('04:00')->timezone('America/Chicago');
64+
Schedule::command('app:process-invoices')
65+
->daily() // Run this task once per day
66+
->at('02:00') // At 2:00 AM
67+
->timezone('America/Chicago'); // In the Chicago timezone
68+
69+
Schedule::command('app:process-latefees')
70+
->daily() // Run this task once per day
71+
->at('04:00') // At 4:00 AM
72+
->timezone('America/Chicago'); // In the Chicago timezone
6473
```
6574

66-
::note
67-
This example is for Laravel version <= 10.
68-
::
75+
:::
76+
77+
:::tabs-item{label="Laravel 10 & Below" icon="i-lucide-eye"}
6978

70-
This is an example how we would set the actual execution time within Laravel itself:
7179
```php [app/Console/Kernel.php]
7280
<?php
7381

@@ -111,4 +119,8 @@ class Kernel extends ConsoleKernel
111119
require base_path('routes/console.php');
112120
}
113121
}
114-
```
122+
```
123+
124+
:::
125+
126+
::

0 commit comments

Comments
 (0)