A package to simply add timelines to Crud's in litsatck.
- Install the package via composer:
composer require litstack/timeline
- Publish and run the migrations:
php artisan vendor:publish --tag=timeline:migrations
php artisan migrate
Add the Timelineable
contract and the HasTimeline
trait to your Model:
use Litstack\Timeline\Contracts\Timelineable;
use Litstack\Timeline\HasTimeline;
class Post extends Model implements Timelineable
{
use HasTimeline;
}
Push a timeline item to your Model:
// Add message to timeline.
$post->addToTimeline('Hello World!')->save();
// With some available options.
$post->addToTimeline('Hello World!')->title('Foo')->showTime()->variant('success')->save();
// Variant danger is available as well.
$post->addToTimeline('Hello World!')->variant('danger')->save();
In your CrudConfig
:
public function show($page)
{
$page->timeline();
}