first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendSMSJob;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class NotifySubEnd extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:notify-sub-end';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
User::with([
|
||||
'products' => fn ($q) => $q->whereNotIn('gateway', [Transaction::GATEWAYS['cafe'], Transaction::GATEWAYS['myket']])->whereDate('expire_at', now()->subDay()),
|
||||
'products.packageName',
|
||||
])->whereHas('products', fn ($q) => $q->whereDate('expire_at', now()->subDay()))->chunkById(300, function ($users) {
|
||||
foreach ($users as $user) {
|
||||
$link = config('redirects.' . str_replace('.', '*', $user->products[0]->packageName->name));
|
||||
dump($user->mobile);
|
||||
SendSMSJob::dispatch([
|
||||
'mobile' => $user->mobile,
|
||||
'message' => "کاربرعزیز
|
||||
اشتراک برنامه {$user->products[0]->packageName->title} برای شما به پایان رسید
|
||||
برای تمدید کلیک کنید
|
||||
$link"
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user