Skip to content

Releases: patiencemanzen/Filtan

v1.0.9

27 Nov 17:34
Compare
Choose a tag to compare

v1.0.8

27 Nov 17:27
Compare
Choose a tag to compare

🎉 New Features

  1. 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

  1. 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.

  2. Configuration Documentation:

    Improved the documentation in the filtan.php configuration file to provide clearer explanations of each configuration option.

🐛 Bug Fixes

  1. 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.

  1. Fork the repository and create a new branch for your contributions.
  2. Make your changes or additions, adhering to the coding guidelines.
  3. Submit a pull request detailing your changes, and our team will review it promptly.

📜 License

MIT

v1.0.7

27 Nov 17:22
Compare
Choose a tag to compare

🎉 New Features

  1. 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

  1. 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.

  2. Configuration Documentation:

    Improved the documentation in the filtan.php configuration file to provide clearer explanations of each configuration option.

🐛 Bug Fixes

  1. 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.

  1. Fork the repository and create a new branch for your contributions.
  2. Make your changes or additions, adhering to the coding guidelines.
  3. Submit a pull request detailing your changes, and our team will review it promptly.

📜 License

MIT

Filtan Release Notes - v1.0.6

27 Nov 12:25
Compare
Choose a tag to compare

🎉 New Features

  1. 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

  1. 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.

  2. Configuration Documentation:

    Improved the documentation in the filtan.php configuration file to provide clearer explanations of each configuration option.

🐛 Bug Fixes

  1. 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.

  1. Fork the repository and create a new branch for your contributions.
  2. Make your changes or additions, adhering to the coding guidelines.
  3. Submit a pull request detailing your changes, and our team will review it promptly.

📜 License

MIT

Filtan v1.0.5

08 Feb 11:40
Compare
Choose a tag to compare

✨ 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

01 Aug 13:18
Compare
Choose a tag to compare
docs: updated README documentation

Stable focus and target match

18 Nov 16:39
6950b6b
Compare
Choose a tag to compare

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

MIT

v1.0.2: Focus on specific function under your QueryFilter

10 Nov 11:35
Compare
Choose a tag to compare

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

MIT

1.0.1 release

11 Aug 13:31
Compare
Choose a tag to compare

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

MIT

Initial Release

03 Aug 08:13
4d157fa
Compare
Choose a tag to compare

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.

License

MIT