- Post Management
- Category Management
Run Composer Require Command
composer require doctype_admin/blog
php artisan DoctypeAdminBlog:install -a
This command will publish
- config file named Blog.php
- views files of post and category
- migrations files
- seed files
php artisan DoctypeAdminBlog:install -c
php artisan DoctypeAdminBlog:install -f
php artisan DoctypeAdminBlog:install -m
php artisan DoctypeAdminBlog:install -d
php artisan migrate
This Package includes two seed
- PostsTableSeeder
- CategoriesTableSeeder
To use specific seed use
php artisan db:seed --class=CategoriesTableSeeder //Seed this first
php artisan db:seed --class=PostsTableSeeder // And then this
If seed class is not found try running composer dump-autoload
- Blog Routes has been changed from prefix admin/post and admin/category to admin/blog/post and admin/blog/category
<?php
return [
/*
|--------------------------------------------------------------------------
| Doctype Admin Post Tagging Feature
|--------------------------------------------------------------------------
|
| This option define whether to use post tagging feature provided by the
| package.This package uses https://github.com/rtconner/laravel-tagging
|
*/
'post_tagging' => true,
/*
|--------------------------------------------------------------------------
| Doctype Admin Blog default prefix
|--------------------------------------------------------------------------
|
| This option defines the default prefix of all routes of blog plugins to
| your admin panel. The default prefix is admin. You can change the prefix
| but we highly recommend to use default one.
*/
'prefix' => 'admin',
/*
|--------------------------------------------------------------------------
| Doctype Admin Blog Middlewares
|--------------------------------------------------------------------------
|
| This option includes all the middleware used by routes og doctype admin
| blog package.
| Note: If you don;t want activity logging of post and category model simply
| remove activity middleware
|
*/
'middleware' => ['web', 'auth', 'activity'],
/*
|--------------------------------------------------------------------------
| Doctype Admin Blog Thmbnail Feature
|--------------------------------------------------------------------------
|
| This option defines whether to use Package's Thumbnail Featured or not
| Default option is true
|
*/
'thumbnail' => true,
/*
|--------------------------------------------------------------------------
| Thumbnail Qualities
|--------------------------------------------------------------------------
|
| These options are default post image and its thumbnail quality
|
|
*/
'image_quality' => 80,
'medium_thumbnail_quality' => 60,
'small_thumbnail_quality' => 30,
/*
|--------------------------------------------------------------------------
| Default Image Fit Size
|--------------------------------------------------------------------------
|
| These option is default post imahe height and width fit size
|
|
*/
'img_width' => 1000,
'img_height' => 800,
'medium_thumbnail_width' => 800,
'medium_thumbnail_height' => 600,
'small_thumbnail_width' => 400,
'small_thumbnail_height' => 300,
];
To add the package route link to be accesable from sidemenu just add following on config/adminlte.php undr key 'menu'
[
'text' => 'Blog',
'icon' => 'fas fa-blog',
'submenu' => [
[
'text' => 'Posts',
'icon' => 'fas fa-file',
'url' => 'admin/blog/post',
],
[
'text' => 'Categories',
'icon' => 'fas fa-bezier-curve',
'url' => 'admin/blog/category',
]
]
],
Scopes | Description |
---|---|
Post::featured()->get() | Retives all featured posts |
Post::featuredLimit($limit)->get() | Retives $limit(type integer) no. of posts |
Post::published()->get() | Retrives published posts |
Post::draft()->get() | Retrives draft posts |
Post::pending()->get() | Retrives pending |
posts |
Doctype admin blog uses facade "Post" to retrive cached data.
Use | Description |
---|---|
Post::allPosts | Retives all posts |
Post::pendingPosts | Retives Pending Posts |
Post::draftPosts | Retrives draft posts |
Post::publishedPosts | Retrives published posts |
Post::blog | Retrives Blog posts |
Post::event | Retrives event posts |
Post::news | Retrives news posts |
Post::job | Retrives job posts |
Post::relatedTagPosts(post,limit) | Retrives limit no. of posts related to post arguement instance tag |
Post::relatedCategoryPosts($post,$limit) | Retrives limit no. of posts related to post arguement instance category |
Post::relatedPosts($post,$limit) | Retrives limit no. of posts related to post arguement instance tag and category |
$post = Post::find($id);
scopeRelatedTagPost = Post::relatedPost($post); //retrives all the related posts to $post using some or all tags used by $post
$scopeRelatedTagPostlimited = Post::relatedPost($post,8); //retrives 8 related post, default limit is 5
similar goes to relatedTagPost and relatedPost.
- relatedTagPost scopes uses tags used by the instance to find out other related post using its tags.
- If you want to use ModelScope provied by doctype admin panel just use ModelScopes on Post Model
- This package uses https://github.com/rtconner/laravel-tagging for tagging posts so you can check it's documentation for further manipulation
- This package uses https://github.com/cviebrock/eloquent-sluggable for slugging post so you can check it's documentation for further manipulation
<?php
namespace doctype_admin\Blog\Models;
use App\User;
use Conner\Tagging\Taggable;
use doctype_admin\Blog\Models\Category;
use doctype_admin\Blog\Traits\PostScopes;
use Illuminate\Database\Eloquent\Model;
use App\Traits\ModelScopes;
use Cviebrock\EloquentSluggable\Sluggable;
class Post extends Model
{
use Taggable, PostScopes, ModelScopes, Sluggable;
protected $guarded = [];
public function save(array $options = [])
{
// If no author has been assigned, assign the current user's id as the author of the post
if (!$this->author_id && Auth::user()) {
$this->author_id = Auth::user()->getKey();
}
return parent::save();
}
public function author()
{
return $this->belongsTo(User::class, 'author_id');
}
public function category()
{
return $this->belongsTo(Category::class, 'category_id');
}
public function getStatusAttribute($attribute)
{
return [
1 => "Pending",
2 => "Draft",
3 => "Published"
][$attribute];
}
/**
* Return the sluggable configuration array for this model.
*
* @return array
*/
public function sluggable()
{
return [
'slug' => [
'source' => 'title'
]
];
}
}
New Thumbnail featured added
How to use thumbnails ? Just use as follows
@foreach ($images as $image)
<img src="{{asset($image->thumbnail('small'))}}"> // For small thumbnail
<img src="{{asset($image->thumbnail('medium'))}}"> // For medium thumbnail
@endforeach
- Better Confile File Control
- Post Analytics
- Algolia Post Search Funtionality
- Maintainabilty
- Better UI
- https://github.com/rtconner/laravel-tagging
- https://github.com/jeroennoten/Laravel-AdminLTE
- https://github.com/cviebrock/eloquent-sluggable
MIT
DOCTYPE NEPAL ||DR.H2SO4