当前位置:网站首页>Laravel scheduled task
Laravel scheduled task
2022-06-24 23:12:00 【Wang Daochang's way of programming】
One 、 Custom task method
php artisan make:command Task
Two 、 Self generated task class
protected $signature = 'command:name';// Name of the task to be performed
public function handle()
{
/* * This method does the specific processing of the task , That is, the operation of data , Available models For example, I want to delete the user table ID by 1 Users of * */
DB::table('user')->where('id',1)->delete();
}
3、 ... and 、 register
# Go to App\Console\kernel.php
protected $commands = [
// Introduce the newly created class
\App\Console\Commands\Task::class
];
protected function schedule(Schedule $schedule){
// This is equivalent to specifying the agreed scheduled execution time , For example, perform the following tasks every minute
// command('command:name') The writing should be consistent with what we just Task In the file $signature identical
$schedule->command('command:name')->everyMinute();
}
Four 、 function
php artisan schedule:run
边栏推荐
- Development specification - parameter verification exception, exception return prompt section
- [untitled]
- 是否需要提高代码阅读能力?这有技巧
- Some updates about a hand slider (6-18, JS reverse)
- Blogs personal blog project details (servlet implementation)
- Selection (028) - what is the output of the following code?
- Research Report on terahertz imaging system industry - market status analysis and development prospect forecast
- Uip1.0 active sending problem understanding
- 监听 Markdown 文件并热更新 Next.js 页面
- Financial management [6]
猜你喜欢

关于某手滑块的一些更新(6-18,js逆向)

Talk about GC mechanism often asked in interview

EMI的主要原因-工模电流

2022 safety officer-b certificate examination question bank and answers

Parental delegation mechanism

Solution to the login error of tangdou people

2022年高压电工考试模拟100题及在线模拟考试

Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis

vulnhub Vegeta: 1

23研考生注意啦!备考期间最容易中招的骗局,居然是它们?!
随机推荐
2022 safety officer-a certificate examination questions and answers
Common sense of resolution
laravel 创建 service层
从客户端到服务器
Blogs personal blog project details (servlet implementation)
Second IPO of Huafang group: grown up in Zanthoxylum bungeanum, trapped in Zanthoxylum bungeanum
Selection (027) - what is the output of the following code?
[WSL] SSH Remote Connection and host port forwarding configuration
Research Report on market supply and demand and strategy of China's solar charging controller industry
China solar thermal market trend report, technical dynamic innovation and market forecast
Simulated 100 questions and online simulated examination of high voltage electrician examination in 2022
Cat write multiline content to file
Vulnhub Vegeta: 1
Memory alignment of structures
laravel用户授权
Financial management [1]
China smallpox vaccine market trend report, technical innovation and market forecast
Non single file component
研究生宿舍大盘点!令人羡慕的研究生宿舍来了!
01_SpingBoot 框架入门