PHP 클래스 MongolidLaravel\MongolidModel

The MongolidLaravel\MongolidModel simply extends the original and framework agnostic model of MongoLid and implements some validation rules using Laravel validation components. Remember, this package is meant to be used with Laravel while the "leroy-merlin\mongolid" is meant to be used with other frameworks or even without any.
상속: extends Mongolid\ActiveRecord
파일 보기 프로젝트 열기: leroy-merlin-br/mongolid-laravel

공개 프로퍼티들

프로퍼티 타입 설명
$errors Illuminate\Support\MessageBag Error message bag.
$localMock Mockery\Mock Public local mock.
$mock Mockery\Mock Public static mock.
$rules array Validation rules.

보호된 프로퍼티들

프로퍼티 타입 설명
$hashedAttributes array List of attribute names which should be hashed on save. For example: array('password');.

공개 메소드들

메소드 설명
__callStatic ( string $name, array $arguments ) : Expectation | void Initiate a mock expectation on the facade.
all ( )
delete ( ) : boolean Overwrites the delete method in order to be able to check for the expectation in the localMock in order to call the delete method into the existing mock and avoid touching the database.
errors ( ) : Illuminate\Support\MessageBag Get the contents of errors attribute.
first ( mixed $query = [], array $projection = [], boolean $useCache = false ) : ActiveRecord Gets the first entity of this kind that matches the query.
firstOrFail ( mixed $query = [], array $projection = [], boolean $useCache = false ) : ActiveRecord Gets the first entity of this kind that matches the query. If no document was found, throws ModelNotFoundException.
firstOrNew ( mixed $id ) : ActiveRecord Gets the first entity of this kind that matches the query. If no document was found, a new entity will be returned with the _id field filled.
isValid ( ) : boolean Verify if the model is valid by running its validation rules, defined on static attribute $rules.
save ( boolean $force = false ) : boolean Save the model to the database if it's valid. This method also checks for the presence of the localMock in order to call the save method into the existing Mock in order not to touch the database.
shouldReceiveDelete ( ) : Expectation Initiate a mock expectation that is specific for the delete method.
shouldReceiveSave ( ) : Expectation Initiate a mock expectation that is specific for the save method.
update ( )
where ( array $query = [], array $projection = [], boolean $useCache = false ) : Cursor Gets a cursor of this kind of entities that matches the query from the database.

보호된 메소드들

메소드 설명
callMockOrParent ( string $method, array $arguments ) : mixed Calls mock method if its have expectations. Calls parent method otherwise.
collection ( ) : MongoDB\Collection Returns the Mongo collection object.
db ( ) : MongoDB\Database Returns the database object (the connection).
getLocalMock ( ) : Mock | Mockery\MockInterface Get a local mock instance.
hasLocalMock ( ) : boolean Check if local mock is set.
hashAttributes ( ) : void Hashes the attributes specified in the hashedAttributes array.
localMockHasExpectationsFor ( string $method ) : boolean Check for a expectation for given method on local mock.
localMockShouldReceive ( string $method ) : Expectation Initiate a mockery expectation that is specific for the given method.

메소드 상세

__callStatic() 공개 정적인 메소드

Initiate a mock expectation on the facade.
public static __callStatic ( string $name, array $arguments ) : Expectation | void
$name string Name of the method being called.
$arguments array Method arguments.
리턴 Mockery\Expectation | void

all() 공개 정적인 메소드

public static all ( )

callMockOrParent() 보호된 정적인 메소드

Calls mock method if its have expectations. Calls parent method otherwise.
protected static callMockOrParent ( string $method, array $arguments ) : mixed
$method string Name of the method being called.
$arguments array Arguments to pass in method call.
리턴 mixed See parent implementation

collection() 보호된 메소드

Returns the Mongo collection object.
protected collection ( ) : MongoDB\Collection
리턴 MongoDB\Collection

db() 보호된 메소드

Returns the database object (the connection).
protected db ( ) : MongoDB\Database
리턴 MongoDB\Database

delete() 공개 메소드

Overwrites the delete method in order to be able to check for the expectation in the localMock in order to call the delete method into the existing mock and avoid touching the database.
public delete ( ) : boolean
리턴 boolean

errors() 공개 메소드

Get the contents of errors attribute.
public errors ( ) : Illuminate\Support\MessageBag
리턴 Illuminate\Support\MessageBag Validation errors

first() 공개 정적인 메소드

Gets the first entity of this kind that matches the query.
public static first ( mixed $query = [], array $projection = [], boolean $useCache = false ) : ActiveRecord
$query mixed MongoDB selection criteria.
$projection array Fields to project in MongoDB query.
$useCache boolean Retrieves the entity through a CacheableCursor.
리턴 Mongolid\ActiveRecord

firstOrFail() 공개 정적인 메소드

Gets the first entity of this kind that matches the query. If no document was found, throws ModelNotFoundException.
public static firstOrFail ( mixed $query = [], array $projection = [], boolean $useCache = false ) : ActiveRecord
$query mixed MongoDB selection criteria.
$projection array Fields to project in Mongo query.
$useCache boolean Retrieves the entity through a CacheableCursor.
리턴 Mongolid\ActiveRecord

firstOrNew() 공개 정적인 메소드

Gets the first entity of this kind that matches the query. If no document was found, a new entity will be returned with the _id field filled.
public static firstOrNew ( mixed $id ) : ActiveRecord
$id mixed Document id.
리턴 Mongolid\ActiveRecord

getLocalMock() 보호된 메소드

Get a local mock instance.
protected getLocalMock ( ) : Mock | Mockery\MockInterface
리턴 Mockery\Mock | Mockery\MockInterface

hasLocalMock() 보호된 메소드

Check if local mock is set.
protected hasLocalMock ( ) : boolean
리턴 boolean

hashAttributes() 보호된 메소드

Hashes the attributes specified in the hashedAttributes array.
protected hashAttributes ( ) : void
리턴 void

isValid() 공개 메소드

Verify if the model is valid by running its validation rules, defined on static attribute $rules.
public isValid ( ) : boolean
리턴 boolean

localMockHasExpectationsFor() 보호된 메소드

Check for a expectation for given method on local mock.
protected localMockHasExpectationsFor ( string $method ) : boolean
$method string Name of the method being checked.
리턴 boolean

localMockShouldReceive() 보호된 메소드

Initiate a mockery expectation that is specific for the given method.
protected localMockShouldReceive ( string $method ) : Expectation
$method string Name of the method being mocked.
리턴 Mockery\Expectation

save() 공개 메소드

Save the model to the database if it's valid. This method also checks for the presence of the localMock in order to call the save method into the existing Mock in order not to touch the database.
public save ( boolean $force = false ) : boolean
$force boolean Force save even if the object is invalid.
리턴 boolean

shouldReceiveDelete() 공개 메소드

Initiate a mock expectation that is specific for the delete method.
public shouldReceiveDelete ( ) : Expectation
리턴 Mockery\Expectation

shouldReceiveSave() 공개 메소드

Initiate a mock expectation that is specific for the save method.
public shouldReceiveSave ( ) : Expectation
리턴 Mockery\Expectation

update() 공개 메소드

public update ( )

where() 공개 정적인 메소드

Gets a cursor of this kind of entities that matches the query from the database.
public static where ( array $query = [], array $projection = [], boolean $useCache = false ) : Cursor
$query array MongoDB selection criteria.
$projection array Fields to project in MongoDB query.
$useCache boolean Retrieves a CacheableCursor instead.
리턴 Mongolid\Cursor\Cursor

프로퍼티 상세

$errors 공개적으로 프로퍼티

Error message bag.
public MessageBag,Illuminate\Support $errors
리턴 Illuminate\Support\MessageBag

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

List of attribute names which should be hashed on save. For example: array('password');.
protected array $hashedAttributes
리턴 array

$localMock 공개적으로 프로퍼티

Public local mock.
public Mock,Mockery $localMock
리턴 Mockery\Mock

$mock 공개적으로 정적으로 프로퍼티

Public static mock.
public static Mock,Mockery $mock
리턴 Mockery\Mock

$rules 공개적으로 정적으로 프로퍼티

Validation rules.
public static array $rules
리턴 array