PHP Class Flarum\Core\Repository\DiscussionRepository

Mostra file Open project: flarum/core Class Usage Examples

Public Methods

Method Description
findOrFail ( integer $id, User $user = null ) : Discussion Find a discussion by ID, optionally making sure it is visible to a certain user, or throw an exception.
getReadIds ( User $user ) : array Get the IDs of discussions which a user has read completely.
query ( ) : Builder Get a new query builder for the discussions table.

Protected Methods

Method Description
scopeVisibleTo ( Builder $query, User $user = null ) : Builder Scope a query to only include records that are visible to a user.

Method Details

findOrFail() public method

Find a discussion by ID, optionally making sure it is visible to a certain user, or throw an exception.
public findOrFail ( integer $id, User $user = null ) : Discussion
$id integer
$user Flarum\Core\User
return Flarum\Core\Discussion

getReadIds() public method

Get the IDs of discussions which a user has read completely.
public getReadIds ( User $user ) : array
$user Flarum\Core\User
return array

query() public method

Get a new query builder for the discussions table.
public query ( ) : Builder
return Illuminate\Database\Eloquent\Builder

scopeVisibleTo() protected method

Scope a query to only include records that are visible to a user.
protected scopeVisibleTo ( Builder $query, User $user = null ) : Builder
$query Illuminate\Database\Eloquent\Builder
$user Flarum\Core\User
return Illuminate\Database\Eloquent\Builder