更新代码
This commit is contained in:
46
app/Admin/Controllers/ProfitController.php
Normal file
46
app/Admin/Controllers/ProfitController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\ProfitLog;
|
||||
use Illuminate\Http\Request;
|
||||
use RuLong\UserAccount\Models\UserAccountLog;
|
||||
|
||||
class ProfitController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$status = $request->status;
|
||||
$start = $request->start;
|
||||
$end = $request->end;
|
||||
$numPerPage = $request->numPerPage ?: 30;
|
||||
|
||||
$profits = ProfitLog::when($status, function ($query) use ($status) {
|
||||
if ($status == 'one') {
|
||||
$query->where('status', 1);
|
||||
} elseif ($status == 'zero') {
|
||||
$query->where('status', 0);
|
||||
}
|
||||
})->when($start && $end, function ($query) use ($start, $end) {
|
||||
return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]);
|
||||
})->when($start && !$end, function ($query) use ($start) {
|
||||
return $query->where('created_at', '>=', $start);
|
||||
})->when(!$start && $end, function ($query) use ($end) {
|
||||
return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end))));
|
||||
})->orderBy('created_at', 'desc')->paginate($numPerPage);
|
||||
|
||||
return view('Admin::profit.index', compact('profits'));
|
||||
}
|
||||
|
||||
public function logs(Request $request, ProfitLog $profit)
|
||||
{
|
||||
$numPerPage = $request->numPerPage ?: 30;
|
||||
|
||||
$logs = UserAccountLog::whereJsonContains('source->no', $profit->end_at->format('Ymd'))
|
||||
->orderBy('user_id', 'asc')
|
||||
->paginate($numPerPage);
|
||||
|
||||
return view('Admin::profit.logs', compact('logs', 'profit'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user