PHP Class App\Repositories\PostRepository

Afficher le fichier Open project: forehalo/materialize-blog Class Usage Examples

Protected Properties

Свойство Type Description
$category Category Model
$model Post Model
$tag Tag Model

Méthodes publiques

Méthode Description
__construct ( Post $post, Category $category, Tag $tag ) BlogRepository constructor.
all ( integer $n = null, boolean $published = true ) : mixed Get all posts.
body ( $id ) : mixed Get post body.
destroy ( $id ) Destroy a post.
doFavorite ( $id ) Update favorite count
getByColumn ( string $value, string $column = 'id' ) Get post by given column.
parseCategory ( $name ) : mixed Get or create new category and return category id.
parseOrigin ( $origin ) : string Parse Markdown.
search ( $key, integer $pagination = 10 ) : mixed Search in all published posts.
store ( $inputs ) Store new post in database.
update ( $inputs, $id ) Update a post.
updatePublish ( $input, $id ) Update post published status

Private Methods

Méthode Description
savePost ( $post, $inputs ) Store post information in database.
syncTags ( $post, string $tags ) Synchronize post tags relation.

Method Details

__construct() public méthode

BlogRepository constructor.
public __construct ( Post $post, Category $category, Tag $tag )
$post app\models\Post
$category app\models\Category
$tag app\models\Tag

all() public méthode

Get all posts.
public all ( integer $n = null, boolean $published = true ) : mixed
$n integer pagination
$published boolean whether fetch unpublished posts.
Résultat mixed

body() public méthode

Get post body.
public body ( $id ) : mixed
$id
Résultat mixed

destroy() public méthode

Destroy a post.
public destroy ( $id )
$id

doFavorite() public méthode

Update favorite count
public doFavorite ( $id )
$id

getByColumn() public méthode

Get post by given column.
public getByColumn ( string $value, string $column = 'id' )
$value string column value.
$column string column name, default={id}

parseCategory() public méthode

Get or create new category and return category id.
public parseCategory ( $name ) : mixed
$name category name
Résultat mixed category id

parseOrigin() public méthode

Parse Markdown.
public parseOrigin ( $origin ) : string
$origin
Résultat string HTML content

store() public méthode

Store new post in database.
public store ( $inputs )
$inputs

update() public méthode

Update a post.
public update ( $inputs, $id )
$inputs
$id post id

updatePublish() public méthode

Update post published status
public updatePublish ( $input, $id )
$input
$id

Property Details

$category protected_oe property

Category Model
protected $category

$model protected_oe property

Post Model
protected $model

$tag protected_oe property

Tag Model
protected $tag