PHP Class RainLab\Blog\Models\Post

Inheritance: extends Mode\Model, use trait October\Rain\Database\Traits\Validation
ファイルを表示 Open project: rainlab/blog-plugin Class Usage Examples

Public Properties

Property 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

Property Type Description
$appends The accessors to append to the model's array form.
$dates array The attributes that should be mutated to dates.

Public Methods

Method 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

Protected Methods

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

Method Details

afterValidate() public method

public afterValidate ( )

beforeSave() public method

public beforeSave ( )

canEdit() public method

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
return boolean

filterFields() public method

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

formatHtml() public static method

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

getHasSummaryAttribute() public method

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

getMenuTypeInfo() public static method

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
return array Returns an array

getPostPageUrl() protected static method

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

getSummaryAttribute() public method

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

resolveMenuItem() public static method

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.
return mixed Returns an array. Returns null if the item cannot be resolved.

scopeFilterCategories() public method

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
return Illuminate\Query\Builder QueryBuilder

scopeIsPublished() public method

public scopeIsPublished ( $query )

scopeListFrontEnd() public method

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

setUrl() public method

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
return 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
return 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