PHP Класс Corcel\Post

Наследование: extends Illuminate\Database\Eloquent\Model
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$appends array The accessors to append to the model's array form.
$dates
$fillable
$postTypes array
$primaryKey
$shortcodes
$table
$with

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

Метод Описание
__construct ( array $attributes = [] )
__get ( string $key ) : string Magic method to return the meta data like the post original fields.
addShortcode ( string $tag, function $function ) Add a shortcode handler
attachment ( ) : Illuminate\Database\Eloquent\Collection Get attachment.
author ( ) : Illuminate\Database\Eloquent\Collection Author relationship.
clearRegisteredPostTypes ( ) Clears any registered post types
comments ( ) : Illuminate\Database\Eloquent\Collection Comments relationship.
fields ( )
getAcfAttribute ( ) : Corcel\Acf\AdvancedCustomFields
getAuthorIdAttribute ( ) : integer Gets the author id attribute.
getContentAttribute ( ) : string Gets the content attribute.
getCreatedAtAttribute ( ) : date Gets the created at attribute.
getExcerptAttribute ( ) : string Gets the excerpt attribute.
getFormat ( ) : boolean | string Get the post format, like the WP get_post_format() function
getImageAttribute ( ) : string Gets the featured image if any Looks in meta the _thumbnail_id field.
getKeywordsAttribute ( ) : array Gets the keywords as array.
getKeywordsStrAttribute ( ) : string Gets the keywords as string.
getMainCategoryAttribute ( ) : string Gets the first term of the first taxonomy found.
getMimeTypeAttribute ( ) : string Gets the mime type attribute.
getParentIdAttribute ( ) : integer Gets the parent id attribute.
getSlugAttribute ( ) : string Gets the slug attribute.
getStatusAttribute ( ) : string Gets the status attribute.
getTermsAttribute ( ) : array Gets all the terms arranged taxonomy => terms[].
getTitleAttribute ( ) : string Gets the title attribute.
getTypeAttribute ( ) : string Gets the type attribute.
getUpdatedAtAttribute ( ) : date Gets the updated at attribute.
getUrlAttribute ( ) : string Gets the url attribute.
hasTerm ( string $taxonomy, string $term ) : boolean Whether the post contains the term or not.
meta ( ) : Corcel\PostMetaCollection Meta data relationship.
newFromBuilder ( array $attributes = [], null $connection = null ) : mixed Overrides default behaviour by instantiating class based on the $attributes->post_type value
newQuery ( boolean $excludeDeleted = true ) : Corcel\PostBuilder Overriding newQuery() to the custom PostBuilder with some interesting methods.
parent ( ) : Corcel\Post Parent post.
registerPostType ( string $name, string $class ) Register your Post Type classes here to have them be instantiated instead of the standard Post model
removeShortcode ( string $tag ) Removes a shortcode handler
revision ( ) : Illuminate\Database\Eloquent\Collection Get revisions from post.
save ( array $options = [] )
scopeHasMeta ( $query, $meta, null $value = null ) : Illuminate\Database\Eloquent\Collection Meta filter scope.
stripShortcodes ( string $content ) : string Process the shortcodes
taxonomies ( ) : Illuminate\Database\Eloquent\Collection Taxonomy relationship.
thumbnail ( ) Return the post thumbnail

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

__construct() публичный Метод

public __construct ( array $attributes = [] )
$attributes array

__get() публичный Метод

Magic method to return the meta data like the post original fields.
public __get ( string $key ) : string
$key string
Результат string

addShortcode() публичный статический Метод

Add a shortcode handler
public static addShortcode ( string $tag, function $function )
$tag string the shortcode tag
$function function the shortcode handling function

attachment() публичный Метод

Get attachment.
public attachment ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

author() публичный Метод

Author relationship.
public author ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

clearRegisteredPostTypes() публичный статический Метод

Clears any registered post types
public static clearRegisteredPostTypes ( )

comments() публичный Метод

Comments relationship.
public comments ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

fields() публичный Метод

public fields ( )

getAcfAttribute() публичный Метод

public getAcfAttribute ( ) : Corcel\Acf\AdvancedCustomFields
Результат Corcel\Acf\AdvancedCustomFields

getAuthorIdAttribute() публичный Метод

Gets the author id attribute.
public getAuthorIdAttribute ( ) : integer
Результат integer

getContentAttribute() публичный Метод

Gets the content attribute.
public getContentAttribute ( ) : string
Результат string

getCreatedAtAttribute() публичный Метод

Gets the created at attribute.
public getCreatedAtAttribute ( ) : date
Результат date

getExcerptAttribute() публичный Метод

Gets the excerpt attribute.
public getExcerptAttribute ( ) : string
Результат string

getFormat() публичный Метод

Get the post format, like the WP get_post_format() function
public getFormat ( ) : boolean | string
Результат boolean | string

getImageAttribute() публичный Метод

Gets the featured image if any Looks in meta the _thumbnail_id field.
public getImageAttribute ( ) : string
Результат string

getKeywordsAttribute() публичный Метод

Gets the keywords as array.
public getKeywordsAttribute ( ) : array
Результат array

getKeywordsStrAttribute() публичный Метод

Gets the keywords as string.
public getKeywordsStrAttribute ( ) : string
Результат string

getMainCategoryAttribute() публичный Метод

Gets the first term of the first taxonomy found.
public getMainCategoryAttribute ( ) : string
Результат string

getMimeTypeAttribute() публичный Метод

Gets the mime type attribute.
public getMimeTypeAttribute ( ) : string
Результат string

getParentIdAttribute() публичный Метод

Gets the parent id attribute.
public getParentIdAttribute ( ) : integer
Результат integer

getSlugAttribute() публичный Метод

Gets the slug attribute.
public getSlugAttribute ( ) : string
Результат string

getStatusAttribute() публичный Метод

Gets the status attribute.
public getStatusAttribute ( ) : string
Результат string

getTermsAttribute() публичный Метод

Gets all the terms arranged taxonomy => terms[].
public getTermsAttribute ( ) : array
Результат array

getTitleAttribute() публичный Метод

Gets the title attribute.
public getTitleAttribute ( ) : string
Результат string

getTypeAttribute() публичный Метод

Gets the type attribute.
public getTypeAttribute ( ) : string
Результат string

getUpdatedAtAttribute() публичный Метод

Gets the updated at attribute.
public getUpdatedAtAttribute ( ) : date
Результат date

getUrlAttribute() публичный Метод

Gets the url attribute.
public getUrlAttribute ( ) : string
Результат string

hasTerm() публичный Метод

Whether the post contains the term or not.
public hasTerm ( string $taxonomy, string $term ) : boolean
$taxonomy string
$term string
Результат boolean

meta() публичный Метод

Meta data relationship.
public meta ( ) : Corcel\PostMetaCollection
Результат Corcel\PostMetaCollection

newFromBuilder() публичный Метод

By default, this method will always return an instance of the calling class. However if post types have been registered with the Post class using the registerPostType() static method, this will now return an instance of that class instead. If the post type string from $attributes->post_type does not appear in the static $postTypes array, then the class instantiated will be the called class (the default behaviour of this method).
public newFromBuilder ( array $attributes = [], null $connection = null ) : mixed
$attributes array
$connection null
Результат mixed

newQuery() публичный Метод

Overriding newQuery() to the custom PostBuilder with some interesting methods.
public newQuery ( boolean $excludeDeleted = true ) : Corcel\PostBuilder
$excludeDeleted boolean
Результат Corcel\PostBuilder

parent() публичный Метод

Parent post.
public parent ( ) : Corcel\Post
Результат Corcel\Post

registerPostType() публичный статический Метод

This method allows you to register classes that will be used for specific post types as defined in the post_type column of the wp_posts table. If a post type is registered here, when a Post object is returned from the posts table it will be automatically converted into the appropriate class for its post type. If you register a Page class for the post_type 'page', then whenever a Post is fetched from the database that has its post_type has 'page', it will be returned as a Page instance, instead of the default and generic Post instance.
public static registerPostType ( string $name, string $class )
$name string The name of the post type (e.g. 'post', 'page', 'custom_post_type')
$class string The class that represents the post type model (e.g. 'Post', 'Page', 'CustomPostType')

removeShortcode() публичный статический Метод

Removes a shortcode handler
public static removeShortcode ( string $tag )
$tag string the shortcode tag

revision() публичный Метод

Get revisions from post.
public revision ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

save() публичный Метод

public save ( array $options = [] )
$options array

scopeHasMeta() публичный Метод

Meta filter scope.
public scopeHasMeta ( $query, $meta, null $value = null ) : Illuminate\Database\Eloquent\Collection
$query
$meta
$value null
Результат Illuminate\Database\Eloquent\Collection

stripShortcodes() публичный Метод

Process the shortcodes
public stripShortcodes ( string $content ) : string
$content string the content
Результат string

taxonomies() публичный Метод

Taxonomy relationship.
public taxonomies ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

thumbnail() публичный Метод

Return the post thumbnail
public thumbnail ( )

Описание свойств

$appends защищенное свойство

The accessors to append to the model's array form.
protected array $appends
Результат array

$dates защищенное свойство

protected $dates

$fillable защищенное свойство

protected $fillable

$postTypes защищенное статическое свойство

protected static array $postTypes
Результат array

$primaryKey защищенное свойство

protected $primaryKey

$shortcodes защищенное статическое свойство

protected static $shortcodes

$table защищенное свойство

protected $table

$with защищенное свойство

protected $with