Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/DiscountList.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Console\Command; | |||||
use App\Discount; | use App\Discount; | ||||
use Illuminate\Console\Command; | |||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
class DiscountList extends Command | class DiscountList extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'discount:list'; | protected $signature = 'discount:list'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'List available (active) discounts'; | protected $description = 'List available (active) discounts'; | ||||
/** | /** | ||||
* Create a new command instance. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function __construct() | |||||
{ | |||||
parent::__construct(); | |||||
} | |||||
/** | |||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
Discount::where('active', true)->orderBy('discount')->get()->each( | Discount::where('active', true)->orderBy('discount')->get()->each( | ||||
function ($discount) { | function ($discount) { | ||||
Show All 18 Lines |