PHP code example of joelbutcher / laravel-archivable
1. Go to this page and download the library: Download joelbutcher/laravel-archivable 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/ */
joelbutcher / laravel-archivable example snippets
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('title');
$table->timestamps();
$table->archivedAt(); // Macro
});
Schema::create('posts', function (Blueprint $table) {
$table->dropArchivedAt();
});
$user = User::first();
$user->archive();
$user->unArchive();
// Check Archive status
$user->isArchived();
$usersWithArchived = User::query()->withArchived();
$onlyArchivedUsers = User::query()->onlyArchived();