You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
806 B
34 lines
806 B
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
|
|
class CheckTransactionCode
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$switch = false;
|
|
if (!$switch) return $next($request);
|
|
|
|
try {
|
|
$user = auth('api')->user();
|
|
|
|
if ($user) {
|
|
$purchase_code = $user['purchase_code'] ?? null;
|
|
if (empty($purchase_code)) return api_response()->error(40002, 'You have not filled in the transaction code');
|
|
}
|
|
} catch (\Exception $exception) {
|
|
return api_response()->error(0, 'error');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|
|
|