Download the PHP package digikraaft/laravel-posts without Composer
On this page you can find all versions of the php package digikraaft/laravel-posts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download digikraaft/laravel-posts
More information about digikraaft/laravel-posts
Files in digikraaft/laravel-posts
Package laravel-posts
Short Description Add posts functionality to your laravel app
License MIT
Homepage https://github.com/digikraaft/laravel-posts
Informations about the package laravel-posts
Add basic Blog/Post functionality to your Laravel app.
Why this package?
This package provides a simple blog functionality for use in a Laravel app. This is an opinionated package. We have had to implement blog functionalities in different Laravel projects and decided to abstract this into a package which can be easily used across our projects. If you find it useful and meets your needs, by all means please use it. Suggested improvements are welcome.
Notes on dependencies
This package uses the following dependencies. Please ensure to follow the installation and usage instructions from their respective repositories:
- Laravel Categories by Rinvex
- Laravel Sluggagle by Spatie
- Laravel Translatable by Spatie
- Laravel ActivityLog by Spatie
- Laravel Model Status by Spatie
- Laravel Tags by Spatie
Usage
Please note that the author $author
must be an eloquent model otherwise an exception Digikraaft\LaravelPosts\Exceptions\InvalidArgumentException
will be thrown.
Installation
You can install the package via composer:
You must publish the migration with:
Run the migration to publish the posts table with:
You can optionally publish the config-file with:
The content of the file that will be published to config/laravel-posts.php
:
Usage
Create a post
Create post with attributes
Please note that the author $author
must be an eloquent model otherwise an exception Digikraaft\LaravelPosts\Exceptions\InvalidArgumentException
will be thrown.
All attributes are optional. If you need to add additional information about a post, you can use the meta
attribute this way:
Create post with custom attributes
If you need to save specific information on a post, you can do it by using custom attributes.
Please ensure you have added the attributes as columns to the posts
migration otherwise, Laravel will throw an exception.
Retrieving Posts
The Post model is a normal eloquent model so all eloquent methods and query builders can be used in retrieving posts.
For more ways to retrieve posts and use the dependencies, check usage instructions of the following packages:
Retrieving basic Post Stats
You can get the reading time of a post:
Using Slug
This package uses Laravel Sluggable by Spatie to handle categories. Please check their usage and installation instructions.
Using Categories
This package uses Laravel Categories by Rinvex to handle categories. Please check the usage and installation instructions. This package however has helper classes to use categories:
Using Tags
This package uses Laravel Tags by Spatie to handle tags. Please check the usage and installation instructions. Here are a few ways to use:
For more tag usage, checkout the documentation
Events
The Digikraaft\LaravelPosts\Events\PostCreatedEvent
event will be dispatched when a post has been created. You can listen to this event and take necessary actions.
An instance of the post will be passed to the event class and can be accessed for use:
Custom model and migration
You can change the model used by extending the Digikraaft\LaravelPosts\Models\Post
class.
You can also change the column name used in the dk_posts
table
(default is model_id
) when using a custom migration. If this is the case, also change the model_primary_key_attribute
key of the laravel-posts
config file.
Testing
Use the command below to run your tests:
More Good Stuff
Check here for more awesome free stuff!
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Tim Oladoyinbo
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-posts with dependencies
illuminate/contracts Version ^10.0
rinvex/laravel-categories Version ^7.1
spatie/laravel-activitylog Version ^4.7
spatie/laravel-model-status Version ^1.14
spatie/laravel-sluggable Version ^3.5
spatie/laravel-tags Version ^4.4
spatie/laravel-translatable Version ^6.5