PHP code example of sbamtr / laravel-auto-hard-deleter
1. Go to this page and download the library: Download sbamtr/laravel-auto-hard-deleter 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/ */
sbamtr / laravel-auto-hard-deleter example snippets
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Prunable;
class SampleModel extends Model
{
use SoftDeletes, Prunable;
/**
* Define which records should be pruned.
*/
public function prunable()
{
// Delete records soft deleted more than 30 days ago
return static::where('deleted_at', '<=', now()->subDays(30));
}
}
use Illuminate\Support\Facades\Schedule;
Schedule::command('model:prune')->daily();