all(), array_merge([ 'per_page' => 'numeric|gt:0', 'page' => 'numeric|gt:0', 'group' => 'required|exists:groups,id', 'category' => 'exists:categories,id', 'type' => 'in:internal,external' ], $this->localeValidationRule())); if($validator->fails()) { return response()->json($validator->errors()); } $exports = Export::query() ->where('group_id', request('group')) ->where('locale', request('locale')) // ->when(request('title'), fn ($q) => $q->whereIn('id', $searchIds)) ->when(request('category'), fn ($q) => $q->where('category_id', request('category'))) ->when(request('unit'), fn ($q) => $q->where('unit', request('unit'))) ->when(request('currency'), fn ($q) => $q->where('currency', request('currency'))) ->when(request('payment'), fn ($q) => $q->where('payment', request('payment'))) ->when(request('send'), fn ($q) => $q->where('send', request('send'))) ->when(request('type'), fn ($q) => $q->where('type', request('type'))); return response()->json([ 'exports' => ExportResource::collection($exports->simplePaginate(request('per_page') ?? 7)), ], 200); } }