PHP 트레잇 Eloquence\Behaviours\CamelCasing

파일 보기 프로젝트 열기: kirkbushell/eloquence

공개 프로퍼티들

프로퍼티 타입 설명
$enforceCamelCase boolean Alter eloquent model behaviour so that model attributes can be accessed via camelCase, but more importantly, attributes also get returned as camelCase fields.

공개 메소드들

메소드 설명
__isset ( $key ) : mixed Because we are changing the case of keys and want to use camelCase throughout the application, whenever we do isset checks we need to ensure that we check using snake_case.
__unset ( $key ) : void Because we are changing the case of keys and want to use camelCase throughout the application, whenever we do unset variables we need to ensure that we unset using snake_case.
attributesToArray ( ) : array Return the attributes for the model, converting field casing if necessary.
getAttribute ( string $key ) : mixed Retrieve a given attribute but allow it to be accessed via alternative case methods (such as camelCase).
getAttributes ( $keys = [] ) : array Converts the attributes to a camel-case version, if applicable.
getDates ( ) : array Overloads the eloquent getDates method to ensure that date field declarations can be made in camelCase but mapped to/from DB in snake_case.
getHidden ( ) : array Overloads eloquent's getHidden method to ensure that hidden fields declared in camelCase are actually hidden and not exposed when models are turned into arrays.
getOriginal ( string $key = null, mixed $default = null ) : array Get the model's original attribute values.
getTrueKey ( $key ) : string Retrieves the true key name for a key.
isCamelCase ( ) : boolean Determines whether the model (or its parent) requires camelcasing. This is required for pivot models whereby they actually depend on their parents for this feature.
relationsToArray ( ) : array Get the model's relationships, converting field casing if necessary.
setAttribute ( string $key, mixed $value ) Overloads the eloquent setAttribute method to ensure that fields accessed in any case are converted to snake_case, which is the defacto standard for field names in databases.
toCamelCase ( mixed $attributes ) : array Converts a given array of attribute keys to the casing required by CamelCaseModel.
toSnakeCase ( $attributes ) : array Converts a given array of attribute keys to the casing required by CamelCaseModel.

보호된 메소드들

메소드 설명
getSnakeKey ( $key ) : string If the field names need to be converted so that they can be accessed by camelCase, then we can do that here.

메소드 상세

__isset() 공개 메소드

Because we are changing the case of keys and want to use camelCase throughout the application, whenever we do isset checks we need to ensure that we check using snake_case.
public __isset ( $key ) : mixed
$key
리턴 mixed

__unset() 공개 메소드

Because we are changing the case of keys and want to use camelCase throughout the application, whenever we do unset variables we need to ensure that we unset using snake_case.
public __unset ( $key ) : void
$key
리턴 void

attributesToArray() 공개 메소드

Return the attributes for the model, converting field casing if necessary.
public attributesToArray ( ) : array
리턴 array

getAttribute() 공개 메소드

Retrieve a given attribute but allow it to be accessed via alternative case methods (such as camelCase).
public getAttribute ( string $key ) : mixed
$key string
리턴 mixed

getAttributes() 공개 메소드

Converts the attributes to a camel-case version, if applicable.
public getAttributes ( $keys = [] ) : array
리턴 array

getDates() 공개 메소드

Overloads the eloquent getDates method to ensure that date field declarations can be made in camelCase but mapped to/from DB in snake_case.
public getDates ( ) : array
리턴 array

getHidden() 공개 메소드

Overloads eloquent's getHidden method to ensure that hidden fields declared in camelCase are actually hidden and not exposed when models are turned into arrays.
public getHidden ( ) : array
리턴 array

getOriginal() 공개 메소드

Get the model's original attribute values.
public getOriginal ( string $key = null, mixed $default = null ) : array
$key string
$default mixed
리턴 array

getSnakeKey() 보호된 메소드

If the field names need to be converted so that they can be accessed by camelCase, then we can do that here.
protected getSnakeKey ( $key ) : string
$key
리턴 string

getTrueKey() 공개 메소드

Retrieves the true key name for a key.
public getTrueKey ( $key ) : string
$key
리턴 string

isCamelCase() 공개 메소드

Determines whether the model (or its parent) requires camelcasing. This is required for pivot models whereby they actually depend on their parents for this feature.
public isCamelCase ( ) : boolean
리턴 boolean

relationsToArray() 공개 메소드

Get the model's relationships, converting field casing if necessary.
public relationsToArray ( ) : array
리턴 array

setAttribute() 공개 메소드

Overloads the eloquent setAttribute method to ensure that fields accessed in any case are converted to snake_case, which is the defacto standard for field names in databases.
public setAttribute ( string $key, mixed $value )
$key string
$value mixed

toCamelCase() 공개 메소드

Converts a given array of attribute keys to the casing required by CamelCaseModel.
public toCamelCase ( mixed $attributes ) : array
$attributes mixed
리턴 array

toSnakeCase() 공개 메소드

Converts a given array of attribute keys to the casing required by CamelCaseModel.
public toSnakeCase ( $attributes ) : array
$attributes
리턴 array

프로퍼티 상세

$enforceCamelCase 공개적으로 프로퍼티

Alter eloquent model behaviour so that model attributes can be accessed via camelCase, but more importantly, attributes also get returned as camelCase fields.
public bool $enforceCamelCase
리턴 boolean