PHP Class Flarum\Core\Post

Inheritance: extends Flarum\Database\AbstractModel, use trait Flarum\Core\Support\EventGeneratorTrait, use trait Flarum\Core\Support\ScopeVisibilityTrait
Datei anzeigen Open project: flarum/core Class Usage Examples

Public Properties

Property Type Description
$type string Should be overwritten by subclasses with the value that is to be stored in the database, which will then be used for mapping the hydrated model instance to the proper subtype.

Protected Properties

Property Type Description
$dates
$models array A map of post types, as specified in the type column, to their classes.
$table

Public Methods

Method Description
boot ( )
discussion ( ) : BelongsTo Define the relationship with the post's discussion.
editUser ( ) : BelongsTo Define the relationship with the user who edited the post.
getModels ( ) : array Get the type-to-model map.
hideUser ( ) : BelongsTo Define the relationship with the user who hid the post.
isVisibleTo ( User $user ) : boolean Determine whether or not this post is visible to the given user.
newFromBuilder ( array $attributes = [], string | null $connection = null ) : static | object Create a new model instance according to the post's type.
scopeAllTypes ( Builder $query ) : Builder Get all posts, regardless of their type, by removing the RegisteredTypesScope global scope constraints applied on this model.
setModel ( string $type, string $model ) : void Set the model for the given post type.
user ( ) : BelongsTo Define the relationship with the post's author.

Method Details

boot() public static method

public static boot ( )

discussion() public method

Define the relationship with the post's discussion.
public discussion ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

editUser() public method

Define the relationship with the user who edited the post.
public editUser ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

getModels() public static method

Get the type-to-model map.
public static getModels ( ) : array
return array

hideUser() public method

Define the relationship with the user who hid the post.
public hideUser ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

isVisibleTo() public method

Determine whether or not this post is visible to the given user.
public isVisibleTo ( User $user ) : boolean
$user User
return boolean

newFromBuilder() public method

Create a new model instance according to the post's type.
public newFromBuilder ( array $attributes = [], string | null $connection = null ) : static | object
$attributes array
$connection string | null
return static | object

scopeAllTypes() public method

Get all posts, regardless of their type, by removing the RegisteredTypesScope global scope constraints applied on this model.
public scopeAllTypes ( Builder $query ) : Builder
$query Illuminate\Database\Eloquent\Builder
return Illuminate\Database\Eloquent\Builder

setModel() public static method

Set the model for the given post type.
public static setModel ( string $type, string $model ) : void
$type string The post type.
$model string The class name of the model for that type.
return void

user() public method

Define the relationship with the post's author.
public user ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

Property Details

$dates protected_oe property

protected $dates

$models protected_oe static_oe property

A map of post types, as specified in the type column, to their classes.
protected static array $models
return array

$table protected_oe property

protected $table

$type public_oe static_oe property

Should be overwritten by subclasses with the value that is to be stored in the database, which will then be used for mapping the hydrated model instance to the proper subtype.
public static string $type
return string