jaikumar0101/laravel-inputbag
Fluent builder to standardize Laravel request inputs for search, pagination, and sorting. Provides sensible defaults, configurable global settings, and custom field mappings so controllers stay clean and API responses remain consistent (array or collection output).
Now you can add custom keys in configuration that will be populated with default standard values
This resolve the $request method when making new input
First final release after testing
Fixed the Service provider issue
Service provider bug fixed
We're excited to announce the first stable release of Laravel InputBag - a fluent builder for standardizing request inputs in Laravel applications!
Laravel InputBag simplifies handling common API request parameters like search, pagination, and sorting. Instead of writing repetitive code in every controller, use our fluent builder to standardize your input processing.
Automatically handles common request parameters:
search - Search querypage - Current page numberper_page - Items per pagesort_by - Sort columnorder_by - Sort directionClean, readable method chaining:
$inputs = InputBag::standard()->toArray();
Easily map custom request fields:
$inputs = InputBag::set('category', 'category_id')
->set('status', 'filter_status', 'active')
->set('min_price', 'price_min', 0)
->standard()
->toCollection();
Customize default values via config file:
'defaults' => [
'per_page' => 15,
'sort_by' => 'id',
'order_by' => 'desc',
]
composer require jaikumar0101/laravel-inputbag
Optionally publish the config:
php artisan vendor:publish --tag="inputbag-config"
Before:
public function index(Request $request)
{
$search = $request->input('search');
$page = $request->input('page', 1);
$perPage = $request->input('per_page', 15);
$sortBy = $request->input('sort_by', 'id');
$orderBy = $request->input('order_by', 'desc');
// ... your query logic
}
After:
public function index()
{
$inputs = InputBag::standard()->toArray();
$products = Product::when($inputs['search'], fn($q) =>
$q->where('name', 'like', '%' . $inputs['search'] . '%'))
->orderBy($inputs['sort_by'], $inputs['order_by'])
->paginate($inputs['per_page']);
return response()->json($products);
}
Full documentation is available in the [README.md](https://github.com/jaikumar0101/laravel-inputbag#readme)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see [LICENSE.md](LICENSE.md) for details
Thank you to everyone who provided feedback and suggestions during development!
What's Next?
Happy coding! 🎊
Made with ❤️ by [Jai Kumar](https://github.com/jaikumar0101)
Full Changelog: https://github.com/Jaikumar0101/laravel-input-bag-request/commits/v1.0.0
How can I help you explore Laravel packages today?