PHP code example of leko-team / laravel-active

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


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

    public function up(): void
    {
        Schema::table('your-table', function (Blueprint $table) {
            $table->boolean('is_active')->default(true)->index();
            $table->timestamp('start_at')->nullable()->index();
            $table->timestamp('end_at')->nullable()->index();
        });
    }

    public function down(): void
    {
        Schema::table('your-table', function (Blueprint $table) {
            $table->dropColumn('end_at');
            $table->dropColumn('start_at');
            $table->dropColumn('is_active');
        });
    }

use ActivityTrait;

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

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

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