|
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\admin;
|
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Services\BetService;
|
|
|
+use Carbon\Carbon;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
use Exception;
|
|
|
@@ -25,7 +26,17 @@ class Bet extends Controller
|
|
|
'status' => ['nullable', 'integer', 'in:1,2'],
|
|
|
'username' => ['nullable', 'string', 'min:1'],
|
|
|
'start_time' => ['required', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
|
|
|
- 'end_time' => ['required', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
|
|
|
+ 'end_time' => ['required', 'date', 'date_format:Y-m-d', 'required_with:start_time',
|
|
|
+ function ($attribute, $value, $fail) {
|
|
|
+ $startTime = request('start_time');
|
|
|
+ if ($startTime) {
|
|
|
+ $start = Carbon::parse($startTime);
|
|
|
+ $end = Carbon::parse($value);
|
|
|
+ if ($end->diffInDays($start) > 30) {
|
|
|
+ $fail('The end time must be within a month of the start time.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
'is_winner' => ['nullable', 'integer', 'in:0,1'],
|
|
|
]);
|
|
|
|
|
|
@@ -49,7 +60,6 @@ class Bet extends Controller
|
|
|
$list = $query->forPage($page, $limit)->get()->toArray();
|
|
|
|
|
|
|
|
|
-
|
|
|
foreach ($list as &$item) {
|
|
|
$item['is_winner'] = null;
|
|
|
$item['created_at'] = date('Y-m-d H:i', strtotime($item['created_at']));
|
|
|
@@ -60,7 +70,7 @@ class Bet extends Controller
|
|
|
$item['is_winner'] = $item['profit'] > 0;
|
|
|
}
|
|
|
}
|
|
|
- $result = ['total' => $count,'total_amount'=>$totalAmount, 'data' => $list];
|
|
|
+ $result = ['total' => $count, 'total_amount' => $totalAmount, 'data' => $list];
|
|
|
} catch (ValidationException $e) {
|
|
|
return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
|
|
|
} catch (Exception $e) {
|