Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/Admin/DiscountsController.php
Show All 10 Lines | class DiscountsController extends Controller | ||||
* Returns (active) discounts defined in the system. | * Returns (active) discounts defined in the system. | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse JSON response | * @return \Illuminate\Http\JsonResponse JSON response | ||||
*/ | */ | ||||
public function index() | public function index() | ||||
{ | { | ||||
$discounts = []; | $discounts = []; | ||||
Discount::withEnvTenant() | Discount::withEnvTenantContext() | ||||
->where('active', true) | ->where('active', true) | ||||
->orderBy('discount') | ->orderBy('discount') | ||||
->get() | ->get() | ||||
->map(function ($discount) use (&$discounts) { | ->map(function ($discount) use (&$discounts) { | ||||
$label = $discount->discount . '% - ' . $discount->description; | $label = $discount->discount . '% - ' . $discount->description; | ||||
if ($discount->code) { | if ($discount->code) { | ||||
$label .= " [{$discount->code}]"; | $label .= " [{$discount->code}]"; | ||||
Show All 18 Lines |