PHP code example of nowendwell / laravel-archivable
1. Go to this page and download the library: Download nowendwell/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/ */
nowendwell / laravel-archivable example snippets
// to archive a User
$user = User::find(1);
$user->archive();
// to unarchive a User
$user = User::withArchived()->find(1);
$user->unarchive();
use Illuminate\Database\Eloquent\Model;
use Nowendwell\LaravelArchivable\Archivable;
class User extends Model
{
use Archivable;
}
User::withArchived()->get(); // returns all users
User::withOutArchived()->get(); // returns users that are not archived, same results as User::all()
User::onlyArchived()->get() // returns only users that have a value in the archived_at column