PHP code example of onamfc / laravel-database-archiver
1. Go to this page and download the library: Download onamfc/laravel-database-archiver 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/ */
onamfc / laravel-database-archiver example snippets
use YourVendor\LaravelDbArchiver\Services\ArchiveService;
class YourController extends Controller
{
public function archiveData(ArchiveService $archiveService)
{
// Archive a specific table
$result = $archiveService->archiveTable('users');
// Archive all configured tables
$results = $archiveService->archiveAll();
// Get status
$status = $archiveService->getStatus();
return response()->json($result);
}
}
'criteria' => [
'column' => 'created_at',
'operator' => '<',
'value' => '6 months ago', // Carbon-parseable string
],
// Or use a closure for complex logic
'criteria' => [
'column' => 'status',
'operator' => '=',
'value' => function () {
return config('app.archive_status');
},
],