rockbuzz / lara-posts
Management of posts
0.0.5
2021-08-20 15:59 UTC
Requires
- php: >=7.3
- rockbuzz/lara-uuid: ^2.0
- spatie/eloquent-sortable: ^3.11
- spatie/laravel-schemaless-attributes: ~1.8
- spatie/laravel-sluggable: ^2.1
Requires (Dev)
- orchestra/testbench: ^5.0
- squizlabs/php_codesniffer: ^3.5
README
Management of posts
Requirements
PHP >=7.2
Install
$ composer require rockbuzz/lara-posts
$ php artisan vendor:publish --provider="Rockbuzz\LaraPosts\ServiceProvider" --tag="migrations"
$ php artisan migrate
Config
$ php artisan vendor:publish --provider="Rockbuzz\LaraPosts\ServiceProvider" --tag="config"
<?php return [ 'tables' => [ 'authors' => 'users' ], 'route_key_name' => 'slug', 'models' => [ 'post' => \Rockbuzz\LaraPosts\Models\Post::class, 'author' => \App\User::class, ] ];
Usage
use Illuminate\Database\Eloquent\Model; use Rockbuzz\LaraPosts\Traits\HavePosts; class User extends Model { use HavePosts; // } $author = User::find(1); $author->posts(): HasMany
use Rockbuzz\LaraPosts\Models\Post; $post = Post::find('uuid'); $post->author(): BelongsTo $post->isDraft(): bool $post->isModerate(): bool $post->isPublished(): bool $post->isArticle(): bool $post->isPodcast(): bool $post->isVideo(): bool
Scope
Post::draft(): Builder Post::moderate(): Builder Post::approved(): Builder Post::published(): Builder Post::articles(): Builder Post::podcasts(): Builder Post::videos(): Builder Post::latestPublished(): Builder
Use Your Model
namespace App; use Rockbuzz\LaraPosts\Models\Post; class YourPost extends Post { // } //set in the configuration file 'models' => [ 'post' => \App\YourPost::class, // ]
License
The Lara Posts is open-sourced software licensed under the MIT license.