1. Go to this page and download the library: Download optix/draftable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
optix / draftable example snippets
$table->timestamp('published_at')->nullable();
class Post extends Model
{
use Draftable;
}
// Only retrieve published records...
$onlyPublished = Post::all();
// Retrieve draft & published records...
$withDrafts = Post::withDrafts()->get();
// Only retrieve draft records...
$onlyDrafts = Post::onlyDrafts()->get();
$post = Post::withDrafts()->first();
// Publish without saving...
$post->setPublished(true);
// Publish and save...
$post->publish(); // or $post->publish(true);
// Draft without saving...
$post->setPublished(false);
// Draft and save...
$post->draft(); // or $post->publish(false);