fix(shayegan): return the document list in the shared table shape
The admin table expects rows and query from TableEngine instead of a custom page payload. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -76,26 +76,25 @@ class ShayeganController extends Controller
|
||||
public function table(Request $request)
|
||||
{
|
||||
if (! Schema::hasTable('shayegan')) {
|
||||
return response()->json(['data' => [], 'total' => 0]);
|
||||
return response()->json([
|
||||
'rows' => [],
|
||||
'query' => [
|
||||
'limit' => (int) $request->input('limit', 20),
|
||||
'page' => 1,
|
||||
'total' => 0,
|
||||
'filters' => $request->input('filters', []),
|
||||
'search' => $request->input('search'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$q = Shayegan::query()->orderByDesc('id');
|
||||
if ($request->filled('sync_status')) {
|
||||
$q->where('sync_status', $request->get('sync_status'));
|
||||
}
|
||||
if ($request->filled('type')) {
|
||||
$q->where('type', $request->get('type'));
|
||||
}
|
||||
$query = Shayegan::query()->orderByDesc('id');
|
||||
\App\DB\Te\TableEngine::create($query, $request)
|
||||
->initSearch(['desc', 'type', 'shayegan_number', 'sync_status'])
|
||||
->select(['*'])
|
||||
->export($query);
|
||||
|
||||
$perPage = min(100, max(10, (int) $request->get('per_page', 20)));
|
||||
$page = $q->paginate($perPage);
|
||||
|
||||
return response()->json([
|
||||
'data' => $page->items(),
|
||||
'total' => $page->total(),
|
||||
'current_page' => $page->currentPage(),
|
||||
'per_page' => $page->perPage(),
|
||||
]);
|
||||
return response()->json($query);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
|
||||
Reference in New Issue
Block a user