PHP Class Corcel\Post

Inheritance: extends Illuminate\Database\Eloquent\Model
Afficher le fichier Open project: jgrossi/corcel Class Usage Examples

Protected Properties

Свойство Type Description
$appends array The accessors to append to the model's array form.
$dates
$fillable
$postTypes array
$primaryKey
$shortcodes
$table
$with

Méthodes publiques

Méthode Description
__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

Method Details

__construct() public méthode

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

__get() public méthode

Magic method to return the meta data like the post original fields.
public __get ( string $key ) : string
$key string
Résultat string

addShortcode() public static méthode

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

attachment() public méthode

Get attachment.
public attachment ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

author() public méthode

Author relationship.
public author ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

clearRegisteredPostTypes() public static méthode

Clears any registered post types
public static clearRegisteredPostTypes ( )

comments() public méthode

Comments relationship.
public comments ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

fields() public méthode

public fields ( )

getAcfAttribute() public méthode

public getAcfAttribute ( ) : Corcel\Acf\AdvancedCustomFields
Résultat Corcel\Acf\AdvancedCustomFields

getAuthorIdAttribute() public méthode

Gets the author id attribute.
public getAuthorIdAttribute ( ) : integer
Résultat integer

getContentAttribute() public méthode

Gets the content attribute.
public getContentAttribute ( ) : string
Résultat string

getCreatedAtAttribute() public méthode

Gets the created at attribute.
public getCreatedAtAttribute ( ) : date
Résultat date

getExcerptAttribute() public méthode

Gets the excerpt attribute.
public getExcerptAttribute ( ) : string
Résultat string

getFormat() public méthode

Get the post format, like the WP get_post_format() function
public getFormat ( ) : boolean | string
Résultat boolean | string

getImageAttribute() public méthode

Gets the featured image if any Looks in meta the _thumbnail_id field.
public getImageAttribute ( ) : string
Résultat string

getKeywordsAttribute() public méthode

Gets the keywords as array.
public getKeywordsAttribute ( ) : array
Résultat array

getKeywordsStrAttribute() public méthode

Gets the keywords as string.
public getKeywordsStrAttribute ( ) : string
Résultat string

getMainCategoryAttribute() public méthode

Gets the first term of the first taxonomy found.
public getMainCategoryAttribute ( ) : string
Résultat string

getMimeTypeAttribute() public méthode

Gets the mime type attribute.
public getMimeTypeAttribute ( ) : string
Résultat string

getParentIdAttribute() public méthode

Gets the parent id attribute.
public getParentIdAttribute ( ) : integer
Résultat integer

getSlugAttribute() public méthode

Gets the slug attribute.
public getSlugAttribute ( ) : string
Résultat string

getStatusAttribute() public méthode

Gets the status attribute.
public getStatusAttribute ( ) : string
Résultat string

getTermsAttribute() public méthode

Gets all the terms arranged taxonomy => terms[].
public getTermsAttribute ( ) : array
Résultat array

getTitleAttribute() public méthode

Gets the title attribute.
public getTitleAttribute ( ) : string
Résultat string

getTypeAttribute() public méthode

Gets the type attribute.
public getTypeAttribute ( ) : string
Résultat string

getUpdatedAtAttribute() public méthode

Gets the updated at attribute.
public getUpdatedAtAttribute ( ) : date
Résultat date

getUrlAttribute() public méthode

Gets the url attribute.
public getUrlAttribute ( ) : string
Résultat string

hasTerm() public méthode

Whether the post contains the term or not.
public hasTerm ( string $taxonomy, string $term ) : boolean
$taxonomy string
$term string
Résultat boolean

meta() public méthode

Meta data relationship.
public meta ( ) : Corcel\PostMetaCollection
Résultat Corcel\PostMetaCollection

newFromBuilder() public méthode

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
Résultat mixed

newQuery() public méthode

Overriding newQuery() to the custom PostBuilder with some interesting methods.
public newQuery ( boolean $excludeDeleted = true ) : Corcel\PostBuilder
$excludeDeleted boolean
Résultat Corcel\PostBuilder

parent() public méthode

Parent post.
public parent ( ) : Corcel\Post
Résultat Corcel\Post

registerPostType() public static méthode

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() public static méthode

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

revision() public méthode

Get revisions from post.
public revision ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

save() public méthode

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

scopeHasMeta() public méthode

Meta filter scope.
public scopeHasMeta ( $query, $meta, null $value = null ) : Illuminate\Database\Eloquent\Collection
$query
$meta
$value null
Résultat Illuminate\Database\Eloquent\Collection

stripShortcodes() public méthode

Process the shortcodes
public stripShortcodes ( string $content ) : string
$content string the content
Résultat string

taxonomies() public méthode

Taxonomy relationship.
public taxonomies ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

thumbnail() public méthode

Return the post thumbnail
public thumbnail ( )

Property Details

$appends protected_oe property

The accessors to append to the model's array form.
protected array $appends
Résultat array

$dates protected_oe property

protected $dates

$fillable protected_oe property

protected $fillable

$postTypes protected_oe static_oe property

protected static array $postTypes
Résultat array

$primaryKey protected_oe property

protected $primaryKey

$shortcodes protected_oe static_oe property

protected static $shortcodes

$table protected_oe property

protected $table

$with protected_oe property

protected $with