ImportLogController.php 481 B

123456789101112131415161718192021
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\ImportLog;
  4. use Illuminate\Http\JsonResponse;
  5. class ImportLogController extends Controller
  6. {
  7. public function index(string $type): JsonResponse
  8. {
  9. $perPage = (int) request('per_page', 10);
  10. $logs = ImportLog::where('type', $type)
  11. ->with('user:id,name')
  12. ->orderByDesc('imported_at')
  13. ->paginate($perPage);
  14. return $this->successResponse(payload: $logs);
  15. }
  16. }