• Laravel
  • PHP
  • Eloquent Filter – Filter models and their Relationships

    Defining The Filter Logic

    Define the filter logic based on the camel cased input key passed to the filter() method.

    • Empty strings and null values are ignored by default.
      • Empty strings and values can be configured not to be ignored by setting protected $allowedEmptyFilters = false; on a filter.
    • If a setup() method is defined it will be called once before any filter methods regardless of input
    • _id is dropped from the end of the input key to define the method so filtering user_id would use the user() method
      • Can be changed with by definining protected $drop_id = false; on a filter
    • Input without a corresponding filter method are ignored
    • The value of the key is injected into the method
    • All values are accessible through the $this->input() method or a single value by key $this->input($key)
    • All Eloquent Builder methods are accessible in $this context in the model filter class.

    Github: https://github.com/Tucker-Eric/EloquentFilter

    Để lại một bình luận

    Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

    1 mins