Releases: patiencemanzen/Filtan
v1.0.9
Full Changelog: v1.0.8...v1.0.9
v1.0.8
🎉 New Features
- Model Integration with Filterable Trait: Added the ability to specify a model using the --model option when creating a filter. The specified model will automatically have the Filterable trait appended to it.
The command will search for the model file within the app directory recursively, ensuring that models in nested directories are correctly located and updated.
🚀 Enhancements
-
Improved Namespace Handling:
Enhanced the namespace generation logic to ensure that namespaces are correctly formatted and trailing slashes are removed.
The namespace is now derived from the filtan_path configuration, ensuring consistency with the directory structure.
-
Configuration Documentation:
Improved the documentation in the filtan.php configuration file to provide clearer explanations of each configuration option.
🐛 Bug Fixes
-
Directory Creation:
Fixed an issue where directories were not being created correctly when no directory name was passed in the path info.Ensured that the directory structure is correctly formed and that the file is placed in the right location.
📖 Usage
To create a new filter and optionally specify a model to append the Filterable
trait to, use the following command:
php artisan filtan:create {filter} --model={model}
Example:
php artisan filtan:create ProductFilter --model=Product
This will create the filter file in the default directory specified in your configuration and append the Filterable
trait to the Product
model.
⚙️ Configuration
Ensure that your filtan.php configuration file is correctly set up:
return [
/**
* -----------------------------------
* Default Query Filters Directory
* ------------------------------------
*
* This is the base directory where your query filters will be stored.
* By default, it is set to 'Http', which means the filters will be
* placed under the 'app/Http' directory.
*/
'filtan_folder' => 'Http',
/**
* ----------------------------------
* Default Query Filters Folder Name
* ----------------------------------
*
* This is the name of the folder that will contain all the query filters.
* By default, it is set to 'QueryFilters'. If you change this name,
* make sure to update the namespacing accordingly.
*/
'filters_folder_name' => 'QueryFilters',
];
🤝 Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository and create a new branch for your contributions.
- Make your changes or additions, adhering to the coding guidelines.
- Submit a pull request detailing your changes, and our team will review it promptly.
📜 License
MIT
v1.0.7
🎉 New Features
- Model Integration with Filterable Trait: Added the ability to specify a model using the --model option when creating a filter. The specified model will automatically have the Filterable trait appended to it.
The command will search for the model file within the app directory recursively, ensuring that models in nested directories are correctly located and updated.
🚀 Enhancements
-
Improved Namespace Handling:
Enhanced the namespace generation logic to ensure that namespaces are correctly formatted and trailing slashes are removed.
The namespace is now derived from the filtan_path configuration, ensuring consistency with the directory structure.
-
Configuration Documentation:
Improved the documentation in the filtan.php configuration file to provide clearer explanations of each configuration option.
🐛 Bug Fixes
-
Directory Creation:
Fixed an issue where directories were not being created correctly when no directory name was passed in the path info.Ensured that the directory structure is correctly formed and that the file is placed in the right location.
📖 Usage
To create a new filter and optionally specify a model to append the Filterable
trait to, use the following command:
php artisan filtan:create {filter} --model={model}
Example:
php artisan filtan:create ProductFilter --model=Product
This will create the filter file in the default directory specified in your configuration and append the Filterable
trait to the Product
model.
⚙️ Configuration
Ensure that your filtan.php configuration file is correctly set up:
return [
/**
* -----------------------------------
* Default Query Filters Directory
* ------------------------------------
*
* This is the base directory where your query filters will be stored.
* By default, it is set to 'Http', which means the filters will be
* placed under the 'app/Http' directory.
*/
'filtan_folder' => 'Http',
/**
* ----------------------------------
* Default Query Filters Folder Name
* ----------------------------------
*
* This is the name of the folder that will contain all the query filters.
* By default, it is set to 'QueryFilters'. If you change this name,
* make sure to update the namespacing accordingly.
*/
'filters_folder_name' => 'QueryFilters',
];
🤝 Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository and create a new branch for your contributions.
- Make your changes or additions, adhering to the coding guidelines.
- Submit a pull request detailing your changes, and our team will review it promptly.
📜 License
MIT
Filtan Release Notes - v1.0.6
🎉 New Features
- Model Integration with Filterable Trait: Added the ability to specify a model using the --model option when creating a filter. The specified model will automatically have the Filterable trait appended to it.
The command will search for the model file within the app directory recursively, ensuring that models in nested directories are correctly located and updated.
🚀 Enhancements
-
Improved Namespace Handling:
Enhanced the namespace generation logic to ensure that namespaces are correctly formatted and trailing slashes are removed.
The namespace is now derived from the filtan_path configuration, ensuring consistency with the directory structure.
-
Configuration Documentation:
Improved the documentation in the filtan.php configuration file to provide clearer explanations of each configuration option.
🐛 Bug Fixes
-
Directory Creation:
Fixed an issue where directories were not being created correctly when no directory name was passed in the path info.Ensured that the directory structure is correctly formed and that the file is placed in the right location.
📖 Usage
To create a new filter and optionally specify a model to append the Filterable
trait to, use the following command:
php artisan filtan:create {filter} --model={model}
Example:
php artisan filtan:create ProductFilter --model=Product
This will create the filter file in the default directory specified in your configuration and append the Filterable
trait to the Product
model.
⚙️ Configuration
Ensure that your filtan.php configuration file is correctly set up:
return [
/**
* -----------------------------------
* Default Query Filters Directory
* ------------------------------------
*
* This is the base directory where your query filters will be stored.
* By default, it is set to 'Http', which means the filters will be
* placed under the 'app/Http' directory.
*/
'filtan_folder' => 'Http',
/**
* ----------------------------------
* Default Query Filters Folder Name
* ----------------------------------
*
* This is the name of the folder that will contain all the query filters.
* By default, it is set to 'QueryFilters'. If you change this name,
* make sure to update the namespacing accordingly.
*/
'filters_folder_name' => 'QueryFilters',
];
🤝 Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository and create a new branch for your contributions.
- Make your changes or additions, adhering to the coding guidelines.
- Submit a pull request detailing your changes, and our team will review it promptly.
📜 License
MIT
Filtan v1.0.5
✨ Enhancements
- Removed default
strtolower
method when passing query-string into custom query-function.
🧼 Cleanup
- Updated default output file contents for better clarity and structure.
- Improved output message when
php artisan make:filter
command is executed.
🐛 Fixes
- Fixed a simple typo in the
php artisan make:filter
command output message.
v1.0.4
docs: updated README documentation
Stable focus and target match
stable relsease
Sometime you may want to pass the intended function in your query filter, 🆗 to not pass through them all!
and well!, it might scale your application to run more faster!, because we have focus! right! 👍 🥳
Right now, what you need to do is pass those function as parameter into your ->filter(QueryFilter, ['function-as-string'])
function! 🥳 !, Let take quick example:
Let suppose we have Our QueryFilter class as:
namespace App\Filters;
use Patienceman\QueryFilter;
class AirlineFilter extends QueryFilter {
/**
* search given string from airlines by name
* @param string $query
*/
public function query(string $query){
$this->builder->where('name', 'LIKE', '%' . $query . '%');
}
/**
* Get where code
* @param string $code
*/
public function code(string $code){
$this->builder->where("code", "some example code");
}
/**
* Get where location
* @param string $location
*/
public function location(string $location){
$this->builder->where("location", "not attached");
}
}
So to work with that, you will: 🛑 remember we want query and code
🥽 :
/**
* Get all airlines that are open for ticket
*
* @param AirlineFilter $filter
* @return JsonResponse
*/
public function index(AirlineFilter $filter) {
$airlines = Airline::where('ticket', 'active)
->filter($filter, ['query', 'code'])
->get();
return AirlineResource::collection($airlines);
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
v1.0.2: Focus on specific function under your QueryFilter
stable relsease
Sometime you may want to pass the intended function in your query filter, 🆗 to not pass through them all!
and well!, it might scale your application to run more faster!, because we have focus! right! 👍 🥳
Right now, what you need to do is pass those function as parameter into your ->filter(QueryFilter, ['function-as-string'])
function! 🥳 !, Let take quick example:
Let suppose we have Our QueryFilter class as:
namespace App\Filters;
use Patienceman\QueryFilter;
class AirlineFilter extends QueryFilter {
/**
* search given string from airlines by name
* @param string $query
*/
public function query(string $query){
$this->builder->where('name', 'LIKE', '%' . $query . '%');
}
/**
* Get where code
* @param string $code
*/
public function code(string $code){
$this->builder->where("code", "some example code");
}
/**
* Get where location
* @param string $location
*/
public function location(string $location){
$this->builder->where("location", "not attached");
}
}
So to work with that, you will: 🛑 remember we want query and code
🥽 :
/**
* Get all airlines that are open for ticket
*
* @param AirlineFilter $filter
* @return JsonResponse
*/
public function index(AirlineFilter $filter) {
$airlines = Airline::where('ticket', 'active)
->filter($filter, ['query', 'code'])
->get();
return AirlineResource::collection($airlines);
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
1.0.1 release
1.0.1- dev release
We all like automated stuff like
php artisan make:cake BananaCake
that what I was doing for you so you don't have always to create files for filter traditional. 🧨
Just one command 🎉
Let us use our current example of the AirPlane Model and create a new filter:
php artisan make:filter AirPlaneFilter
so it will create the filter file for u, Just in ```bash App\Services\Filters ``
namespace App\Services\Filters;
use Patienceman\Filtan\QueryFilter;
class AirPlaneFilter extends QueryFilter {
/**
* public function query($query) {
* $this->builder->where('name', 'LIKE', '%' . . '%')
* }
*/
}
🔥 🔥 What best move we make: in the world?
So you may want even to specify the custom path for your filter, Just relax and add it in front of your filter name.
Let's take again our current example.
php artisan make:filter Model/AirPlaneFilter
👋 👋 That is just what magic can make, awesome right?
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
Initial Release
Filtan from Patienceman
Flltan is fast and reusable laravel package for custom model query filters
Installation
To install the package don't require much requirement except to paste the following compand in laravel terminal, and the you're good to go.
composer require patienceman/filtan
Usage
In your App/Services directory, create new folrder called Filters, where you gonna put all of your model filter files.
After everything, you can add your custom model filter file, let take example of App/Services/Filters/AirplaneFilters
class.
namespace App\Services\Filters;
use Patienceman\Filtan\QueryFilter;
class AirplaneFilter extends QueryFilter {
public function query(string $query){
$this->builder->where('name', 'LIKE', '%' . $query . '%');
}
}
So now you have your filters function to be applied when new AirplaneModel query called!,
We need to communicate to model and tell that we have it filters, so that we can call it anytime!!,
So let use filterable trait to enable filter builder.
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Patienceman\Filtan\Filterable;
class Airplane extends Model {
use HasFactory, Filterable;
}
Boom Boom, from now on, we are able call our fiter anytime, any place that need Airplane model, so let see how we can use this in our controller
namespace App\Http\Controllers\ApiControllers;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Services\Filters\CompanyFilter;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class AirplaneController extends Controller {
/**
* Display a listing of the resource.
*
* @return JsonResponse
*/
public function index(CompanyFilter $filter): JsonResponse {
$planes = Airplane::allPlanes()->filter($filter)->get();
return successResponse(
AirplaneResource::collection($planes),
AirplaneAlert::DISPLAY_MESSAGE
);
}
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.