Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. class SetStatus extends Command
  2. {
  3.  
  4. protected $signature = 'SetStatus:cron';
  5.  
  6. public function handle()
  7. {
  8. //o código ta uma zona apenas pra teste...
  9. $sql = 'select id from promotions where dt_end < NOW()';
  10. $dados = DB::select($sql);
  11. foreach($dados as $i)
  12. {
  13. $updateStatus = 'update promotions set status = "inativo" where id IN ('.$i->id.')';
  14. $return = DB::update($updateStatus);
  15. }
  16. var_dump($return);
  17. }
  18.  
  19. protected $commands = [
  20. CommandsSetStatus::class,
  21. ];
  22.  
  23. protected function schedule(Schedule $schedule)
  24. {
  25. $schedule->command('SetStatus:cron')->everyMinute();
  26. }
  27.  
  28. php artisan SetStatus:cron
  29. php c:/projetos/marcelo/painel/artisan schedule:run
  30.  
  31. # crontab -e 00 * * * * /usr/local/bin/php /home/pedrodelfino/meu-script.php
  32.  
  33. * * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement