order-food-admin/app/Console/Commands/SendTicketForAllUser.php

52 lines
1.0 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Carbon\Carbon;
use App\Models\User;
class SendTicketForAllUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'milk-tea:send_ticket_for_all_user {ticket_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = '给领取过券的人发券';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$ticket_id = $this->argument('ticket_id');
foreach(User::where('register_gift', 1)->orderBy('id', 'asc')->get() as $user) {
$user->sendTicket($ticket_id, 0, '系统后台发送');
$this->info($user->id.':执行成功');
}
$this->info('执行成功');
}
}