PHP Class RainLab\Blog\Models\Post

Inheritance: extends Mode\Model, use trait October\Rain\Database\Traits\Validation
Afficher le fichier Open project: rainlab/blog-plugin Class Usage Examples

Méthodes publiques

Свойство Type Description
$allowedSortingOptions array The attributes on which the post list can be ordered
$attachMany
$belongsTo * Relations
$belongsToMany
$implement
$preview
$rules * Validation
$table
$translatable Attributes that support translation, if available.

Protected Properties

Свойство Type Description
$appends The accessors to append to the model's array form.
$dates array The attributes that should be mutated to dates.

Méthodes publiques

Méthode Description
afterValidate ( )
beforeSave ( )
canEdit ( Backend\Models\User $user ) : boolean Used to test if a certain user has permission to edit post, returns TRUE if the user is the owner or has other posts access.
filterFields ( $fields, $context = null ) : void Limit visibility of the published-button
formatHtml ( $input, $preview = false )
getHasSummaryAttribute ( ) : boolean Used by "has_summary", returns true if this post uses a summary (more tag)
getMenuTypeInfo ( string $type ) : array Handler for the pages.menuitem.getTypeInfo event.
getSummaryAttribute ( ) : string Used by "summary", if no excerpt is provided, generate one from the content.
resolveMenuItem ( RainLab\Pages\Classes\MenuItem $item, string $url, Cms\Classes\Theme $theme ) : mixed Handler for the pages.menuitem.resolveItem event.
scopeFilterCategories ( Illuminate\Query\Builder $query, array $categories ) : Illuminate\Query\Builder Allows filtering for specifc categories
scopeIsPublished ( $query )
scopeListFrontEnd ( $query, array $options ) : self Lists posts for the front end
setUrl ( string $pageName, Cms\Classes\Controller $controller ) Sets the "url" attribute with a URL to this object

Méthodes protégées

Méthode Description
getPostPageUrl ( $pageCode, $category, $theme ) Returns URL of a post page.

Method Details

afterValidate() public méthode

public afterValidate ( )

beforeSave() public méthode

public beforeSave ( )

canEdit() public méthode

Used to test if a certain user has permission to edit post, returns TRUE if the user is the owner or has other posts access.
public canEdit ( Backend\Models\User $user ) : boolean
$user Backend\Models\User
Résultat boolean

filterFields() public méthode

Limit visibility of the published-button
public filterFields ( $fields, $context = null ) : void
Résultat void

formatHtml() public static méthode

public static formatHtml ( $input, $preview = false )

getHasSummaryAttribute() public méthode

Used by "has_summary", returns true if this post uses a summary (more tag)
public getHasSummaryAttribute ( ) : boolean
Résultat boolean

getMenuTypeInfo() public static méthode

Returns a menu item type information. The type information is returned as array with the following elements: - references - a list of the item type reference options. The options are returned in the ["key"] => "title" format for options that don't have sub-options, and in the format ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional, required only if the menu item type requires references. - nesting - Boolean value indicating whether the item type supports nested items. Optional, false if omitted. - dynamicItems - Boolean value indicating whether the item type could generate new menu items. Optional, false if omitted. - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to resolve the item URL.
public static getMenuTypeInfo ( string $type ) : array
$type string Specifies the menu item type
Résultat array Returns an array

getPostPageUrl() protected static méthode

Returns URL of a post page.
protected static getPostPageUrl ( $pageCode, $category, $theme )

getSummaryAttribute() public méthode

Returns the HTML content before the tag or a limited 600 character version.
public getSummaryAttribute ( ) : string
Résultat string

resolveMenuItem() public static méthode

Returns information about a menu item. The result is an array with the following keys: - url - the menu item URL. Not required for menu item types that return all available records. The URL should be returned relative to the website root and include the subdirectory, if any. Use the Url::to() helper to generate the URLs. - isActive - determines whether the menu item is active. Not required for menu item types that return all available records. - items - an array of arrays with the same keys (url, isActive, items) + the title key. The items array should be added only if the $item's $nesting property value is TRUE.
public static resolveMenuItem ( RainLab\Pages\Classes\MenuItem $item, string $url, Cms\Classes\Theme $theme ) : mixed
$item RainLab\Pages\Classes\MenuItem Specifies the menu item.
$url string Specifies the current page URL, normalized, in lower case The URL is specified relative to the website root, it includes the subdirectory name, if any.
$theme Cms\Classes\Theme Specifies the current theme.
Résultat mixed Returns an array. Returns null if the item cannot be resolved.

scopeFilterCategories() public méthode

Allows filtering for specifc categories
public scopeFilterCategories ( Illuminate\Query\Builder $query, array $categories ) : Illuminate\Query\Builder
$query Illuminate\Query\Builder QueryBuilder
$categories array List of category ids
Résultat Illuminate\Query\Builder QueryBuilder

scopeIsPublished() public méthode

public scopeIsPublished ( $query )

scopeListFrontEnd() public méthode

Lists posts for the front end
public scopeListFrontEnd ( $query, array $options ) : self
$options array Display options
Résultat self

setUrl() public méthode

Sets the "url" attribute with a URL to this object
public setUrl ( string $pageName, Cms\Classes\Controller $controller )
$pageName string
$controller Cms\Classes\Controller

Property Details

$allowedSortingOptions public_oe static_oe property

The attributes on which the post list can be ordered
public static array $allowedSortingOptions
Résultat array

$appends protected_oe property

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

$attachMany public_oe property

public $attachMany

$belongsTo public_oe property

* Relations
public $belongsTo

$belongsToMany public_oe property

public $belongsToMany

$dates protected_oe property

The attributes that should be mutated to dates.
protected array $dates
Résultat array

$implement public_oe property

public $implement

$preview public_oe property

public $preview

$rules public_oe property

* Validation
public $rules

$table public_oe property

public $table

$translatable public_oe property

Attributes that support translation, if available.
public $translatable