PHP code example of leko-team / laravel-published

1. Go to this page and download the library: Download leko-team/laravel-published 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/ */

    

leko-team / laravel-published example snippets


php artisan make:migration add_published_at_column_in_`your-table`_table

Schema::table('your-table', function (Blueprint $table) {
    $table->timestamp('published_at')->nullable()->index();
});

use PublishedTrait;

$review = Review::first();
$review->publish();

$review = Review::first();
$review->publish(pass here carbon entity);

$review = Review::first();
$review->unpublish();

$review = Review::notPublished()->get();

$review = Review::withUnpublished()->get();

$review = Review::withoutPublished()->get();