Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/Admin/WalletsController.php
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | public function update(Request $request, $id) | ||||
if (empty($wallet) || !Auth::guard()->user()->canRead($wallet)) { | if (empty($wallet) || !Auth::guard()->user()->canRead($wallet)) { | ||||
return $this->errorResponse(404); | return $this->errorResponse(404); | ||||
} | } | ||||
if (array_key_exists('discount', $request->input())) { | if (array_key_exists('discount', $request->input())) { | ||||
if (empty($request->discount)) { | if (empty($request->discount)) { | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->save(); | $wallet->save(); | ||||
} elseif ($discount = Discount::withEnvTenant()->find($request->discount)) { | } elseif ($discount = Discount::withEnvTenantContext()->find($request->discount)) { | ||||
$wallet->discount()->associate($discount); | $wallet->discount()->associate($discount); | ||||
$wallet->save(); | $wallet->save(); | ||||
} | } | ||||
} | } | ||||
$response = $wallet->toArray(); | $response = $wallet->toArray(); | ||||
if ($wallet->discount) { | if ($wallet->discount) { | ||||
Show All 10 Lines |