Blog - systeminc/laravel-admin GitHub Wiki
You could access our package Blog
instance with SLA::blog()
.
i.e. SLA::blog()->posts()
or SLA::blog()->categories()
or SLA::blog()->comments()
we will return you appropriate Query Builder
.
You could call a method to get Query Builder
, or you could call a property to get a Collection
.
Posts
SLA::blog()->posts()
you get Query Builder
so you have a basic idea how it works.
In case you want to create a Post
outside our admin panel, these are available columns:
SLA::blog()->posts()->create([
'blog_category_id', (int default(null))
'uri_id', (string)
'title', (string)
'thumb', (string)
'content', (string)
'excerpt', (string)
'visible', (int default(0))
'meta_title', (string)
'meta_description', (text)
'meta_keywords', (string)
]);
Get all comments for single post:
SLA::blog()->posts()->find($post_id)->comments
return you a relationship hasMany
or SLA::blog()->posts('my-first-blog')->comments
Get Category for single post:
SLA::blog()->posts()->find($post_id)->categories
return you a relationship belongsTo
or SLA::blog()->posts('my-first-blog')->categories
Comments
SLA::blog()->comments()
you get Query Builder
same as SLA::blog()->posts()
Get post for single comment:
SLA::blog()->comments()->find($comment_id)->post
return you a relationship belongsTo
.
Write comment to post
SLA::blog()->posts('my-first-blog')->comments()->create([
'name', (string)
'email', (string)
'content', (text)
'approved', (int) (default 0)
});
Category
SLA::blog()->categories()
your get Query Builder
same as SLA::blog()->posts()