PHP code example of binbytes / laravel-model-media-backup
1. Go to this page and download the library: Download binbytes/laravel-model-media-backup 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/ */
binbytes / laravel-model-media-backup example snippets
return [
/*
* Models from which you want to take media for backup
*/
'models' => [
// Example 'App\User'
],
/*
* Backup FILESYSTEM_DRIVER name on which you want to take backup
*/
'backup_disk' => null, // FILESYSTEM_DRIVER
/*
* Number of records to be chunk in backup process
*/
'chunk_size' => 100,
/*
* Notification configuration
*/
'notification' => [
/*
* Email address where you want to receive email alert
*/
'mail_to' => null,
/*
* Here you can specify the notifiable to which the notifications should be sent. The default
*
* notifiable will use the variables specified in this config file.
*/
'notifiable' => \BinBytes\ModelMediaBackup\Notifications\Notifiable::class,
'notifications' => [
\BinBytes\ModelMediaBackup\Notifications\Notifications\MediaBackupSuccessful::class,
],
],
];
namespace App;
use BinBytes\ModelMediaBackup\Traits\HasBackupRecords;
use Illuminate\Database\Eloquent\Model;
class YourEloquentModel extends Model
{
use HasBackupRecords;
/**
* Media file associated with record
* @return string|array
*/
public function backupFiles()
{
return $this->path(); // Full path of your media file OR array of paths
}
}
/**
* Select records to processed
*/
public static function backupRecords()
{
return self::latest()
->whereDate('created_at', Carbon::yesterday()->toDateString());
}