PHP 클래스 EloquentFilter\ModelFilter

파일 보기 프로젝트 열기: tucker-eric/eloquentfilter

공개 프로퍼티들

프로퍼티 타입 설명
$relations array Related Models that have ModelFilters as well as the method on the ModelFilter As [relatedModel => [input_key1, input_key2]].

보호된 프로퍼티들

프로퍼티 타입 설명
$allRelations array Container for all relations (local and related ModelFilters).
$drop_id boolean Drop _id from the end of input keys when referencing methods.
$input array Array of input to filter.
$localRelatedFilters array (This allows us to not be required to define a filter for the related models).
$query Illuminate\Database\Eloquent\Builder
$relationsEnabled boolean This is to be able to bypass relations if we are filtering a joined table.

공개 메소드들

메소드 설명
__call ( $method, $args ) Handle calling methods on the query object.
__construct ( $query, array $input = [], boolean $relationsEnabled = true ) ModelFilter constructor.
addRelated ( $relation, Closure $closure ) Locally defines a relation filter method that will be called in the context of the related model.
callRelatedLocalSetup ( $related, $query )
disableRelations ( ) Disable querying relations (Mainly for joined tables as the related model isn't queried).
dropIdSuffix ( null $bool = null ) : boolean Set to drop _id from input. Mainly for testing.
enableRelations ( ) Enable querying relations.
filterInput ( ) Filter with input array.
filterJoinedRelation ( $related ) Run the filter on models that already have their tables joined.
filterRelations ( ) Filter relationships defined in $this->relations array.
filterUnjoinedRelation ( $related ) Filters by a relationship that isn't joined by using that relation's ModelFilter.
getAllRelations ( ) : array Returns all local relations and relations requiring other Model's Filter's.
getFilterMethod ( $key ) : string
getJoinedTables ( ) : array Gets all the joined tables.
getLocalRelation ( string $related ) : array
getRelatedFilter ( $relation ) : mixed Get the model filter of a related model.
getRelatedFilterInput ( $related ) : array Get input to pass to a related Model's Filter.
getRelatedModel ( $relation ) : Model Get an empty instance of a related model.
getRelatedTable ( $relation ) : string Get the table name from a relationship.
getRelationConstraints ( string $relation ) : array Get all input to pass through related filters and local closures as an array.
handle ( ) : Builder Handle all filters.
input ( null $key = null, null $default = null ) : array | mixed | null Retrieve input by key or all input as array.
push ( $key, null $value = null ) Add values to filter by if called in setup().
related ( $relation, $column, null $operator = null, null $value = null, string $boolean = 'and' ) Add a where constraint to a relationship.
relationIsFilterable ( $relation ) : boolean Check to see if there is input or locally defined methods for the given relation.
relationIsJoined ( $relation ) : boolean Checks if the relation to filter's table is already joined.
relationIsLocal ( $related ) : boolean Checks to see if there are locally defined relations to filter.
relationUsesFilter ( $related ) : boolean Checks if there is input that should be passed to a related Model Filter.
relationsEnabled ( ) : boolean Checks if filtering by relations is enabled.
removeEmptyInput ( array $input ) : array Remove empty strings from the input array.

메소드 상세

__call() 공개 메소드

Handle calling methods on the query object.
public __call ( $method, $args )
$method
$args

__construct() 공개 메소드

ModelFilter constructor.
public __construct ( $query, array $input = [], boolean $relationsEnabled = true )
$query
$input array
$relationsEnabled boolean

addRelated() 공개 메소드

Locally defines a relation filter method that will be called in the context of the related model.
public addRelated ( $relation, Closure $closure )
$relation
$closure Closure

callRelatedLocalSetup() 공개 메소드

public callRelatedLocalSetup ( $related, $query )

disableRelations() 공개 메소드

Disable querying relations (Mainly for joined tables as the related model isn't queried).
public disableRelations ( )

dropIdSuffix() 공개 메소드

Set to drop _id from input. Mainly for testing.
public dropIdSuffix ( null $bool = null ) : boolean
$bool null
리턴 boolean

enableRelations() 공개 메소드

Enable querying relations.
public enableRelations ( )

filterInput() 공개 메소드

Filter with input array.
public filterInput ( )

filterJoinedRelation() 공개 메소드

Run the filter on models that already have their tables joined.
public filterJoinedRelation ( $related )
$related

filterRelations() 공개 메소드

Filter relationships defined in $this->relations array.
public filterRelations ( )

filterUnjoinedRelation() 공개 메소드

Filters by a relationship that isn't joined by using that relation's ModelFilter.
public filterUnjoinedRelation ( $related )
$related

getAllRelations() 공개 메소드

Returns all local relations and relations requiring other Model's Filter's.
public getAllRelations ( ) : array
리턴 array

getFilterMethod() 공개 메소드

public getFilterMethod ( $key ) : string
$key
리턴 string

getJoinedTables() 공개 메소드

Gets all the joined tables.
public getJoinedTables ( ) : array
리턴 array

getLocalRelation() 공개 메소드

public getLocalRelation ( string $related ) : array
$related string
리턴 array

getRelatedFilter() 공개 메소드

Get the model filter of a related model.
public getRelatedFilter ( $relation ) : mixed
$relation
리턴 mixed

getRelatedFilterInput() 공개 메소드

Get input to pass to a related Model's Filter.
public getRelatedFilterInput ( $related ) : array
$related
리턴 array

getRelatedModel() 공개 메소드

Get an empty instance of a related model.
public getRelatedModel ( $relation ) : Model
$relation
리턴 Illuminate\Database\Eloquent\Model

getRelatedTable() 공개 메소드

Get the table name from a relationship.
public getRelatedTable ( $relation ) : string
$relation
리턴 string

getRelationConstraints() 공개 메소드

Get all input to pass through related filters and local closures as an array.
public getRelationConstraints ( string $relation ) : array
$relation string
리턴 array

handle() 공개 메소드

Handle all filters.
public handle ( ) : Builder
리턴 Illuminate\Database\Eloquent\Builder

input() 공개 메소드

Retrieve input by key or all input as array.
public input ( null $key = null, null $default = null ) : array | mixed | null
$key null
$default null
리턴 array | mixed | null

push() 공개 메소드

Will ONLY filter relations if called on additional method.
public push ( $key, null $value = null )
$key
$value null

relationIsFilterable() 공개 메소드

Check to see if there is input or locally defined methods for the given relation.
public relationIsFilterable ( $relation ) : boolean
$relation
리턴 boolean

relationIsJoined() 공개 메소드

Checks if the relation to filter's table is already joined.
public relationIsJoined ( $relation ) : boolean
$relation
리턴 boolean

relationIsLocal() 공개 메소드

Checks to see if there are locally defined relations to filter.
public relationIsLocal ( $related ) : boolean
$related
리턴 boolean

relationUsesFilter() 공개 메소드

Checks if there is input that should be passed to a related Model Filter.
public relationUsesFilter ( $related ) : boolean
$related
리턴 boolean

relationsEnabled() 공개 메소드

Checks if filtering by relations is enabled.
public relationsEnabled ( ) : boolean
리턴 boolean

removeEmptyInput() 공개 메소드

Remove empty strings from the input array.
public removeEmptyInput ( array $input ) : array
$input array
리턴 array

프로퍼티 상세

$allRelations 보호되어 있는 프로퍼티

Container for all relations (local and related ModelFilters).
protected array $allRelations
리턴 array

$drop_id 보호되어 있는 프로퍼티

Drop _id from the end of input keys when referencing methods.
protected bool $drop_id
리턴 boolean

$input 보호되어 있는 프로퍼티

Array of input to filter.
protected array $input
리턴 array

$localRelatedFilters 보호되어 있는 프로퍼티

(This allows us to not be required to define a filter for the related models).
protected array $localRelatedFilters
리턴 array

$query 보호되어 있는 프로퍼티

protected Builder,Illuminate\Database\Eloquent $query
리턴 Illuminate\Database\Eloquent\Builder

$relations 공개적으로 프로퍼티

Related Models that have ModelFilters as well as the method on the ModelFilter As [relatedModel => [input_key1, input_key2]].
public array $relations
리턴 array

$relationsEnabled 보호되어 있는 프로퍼티

This is to be able to bypass relations if we are filtering a joined table.
protected bool $relationsEnabled
리턴 boolean