58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Coupon;
|
|
use App\Traits\GenerateBR;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Http\Request;
|
|
|
|
class RegenBRBase extends Command
|
|
{
|
|
use GenerateBR;
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
|
|
protected $signature = 'coupons:regen-base';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
|
|
protected $description = 'Re-generate coupons base image';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$publishedCoupons = Coupon::where('coupon_published', 1)->get();
|
|
|
|
foreach ($publishedCoupons as $coupon)
|
|
{
|
|
$br_path = $this->generateBase(new Request(), $coupon);
|
|
$coupon->coupon_image = $br_path;
|
|
$coupon->save();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|