PHP Интерфейс Mongolid\Model\PolymorphableInterface

See the docblock of the polymorph method for more details.
См. также: Mongolid\DataMapper\EntityAssembler
Показать файл Открыть проект

Открытые методы

Метод Описание
polymorph ( ) : mixed The polymorphic method is something that may be implemented in order to make a model polymorphic. For example: You may have three models within the same collection: Content, ArticleContent and VideoContent.

Описание методов

polymorph() публичный метод

By implementing the polymorph method it is possible to retrieve an ArticleContent or a VideoContent object object by simply querying within the Content model using first, find, where or all. Example: public function polymorph() { if ($this->video != null) { $obj = new VideoContent; $obj->fill($this->attributes); return $obj; } else { return $this; } } In the example above, if you call Content::first() and the content returned have the key video set, then the object returned will be a VideoContent instead of a Content.
public polymorph ( ) : mixed
Результат mixed