PHPackages                             binbytes/laravel-model-media-backup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. binbytes/laravel-model-media-backup

ActiveLibrary

binbytes/laravel-model-media-backup
===================================

Take media backup for model in Laravel.

1.0.0(7y ago)122MITPHPPHP ^7.0

Since Dec 14Pushed 7y ago3 watchersCompare

[ Source](https://github.com/binbytes/laravel-model-media-backup)[ Packagist](https://packagist.org/packages/binbytes/laravel-model-media-backup)[ Docs](https://github.com/binbytes/laravel-model-media-backup)[ RSS](/packages/binbytes-laravel-model-media-backup/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Laravel Model Media Backup
==========================

[](#laravel-model-media-backup)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d5417b3b191f20d15837f02d7f88a2b1c24d544ecf6b15d20fcc2c28c4770bae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696e62797465732f6c61726176656c2d6d6f64656c2d6d656469612d6261636b75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/binbytes/laravel-model-media-backup)[![Build Status](https://camo.githubusercontent.com/c278dc429459434374d5cf2ced0f8b8698f22abec8769ce64a0074e7bcceb100/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62696e62797465732f6c61726176656c2d6d6f64656c2d6d656469612d6261636b75702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/binbytes/laravel-model-media-backup)[![StyleCI](https://camo.githubusercontent.com/deb087150b247b3bd4ee985722edb962247a63254ca9fbc4c2af7745f2fc97ad/68747470733a2f2f7374796c6563692e696f2f7265706f732f3136313734373439342f736869656c64)](https://styleci.io/repos/161747494)[![Total Downloads](https://camo.githubusercontent.com/f303248d52adc0cf07153349c7c53b7a880fd20192d1a1eff9b7f92215ab8145/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696e62797465732f6c61726176656c2d6d6f64656c2d6d656469612d6261636b75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/binbytes/laravel-model-media-backup)

Take newly added media backup associated with any model rather than full backup on daily basis.

This package will be useful in the case where you have lot of media/attachment with any models but rather than taking all media directories each day it might be better to just take newly added media.

BinBytes is an web &amp; mobile application development agency in Rajkot, India. You'll find an overview of all our services [on our website](https://binbytes.com).

Installation
------------

[](#installation)

You can install this package via composer using:

```
$ composer require binbytes/laravel-model-media-backup
```

The package will automatically register itself.

To publish the config file to `config/modelmediabackup.php` run:

```
php artisan vendor:publish --provider="BinBytes\ModelMediaBackup\ModelMediaBackupServiceProvider"
```

This will publish a file `modelmediabackup.php` in your config directory with the following contents:

```
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,
        ],
    ],
];
```

Usage
-----

[](#usage)

After you've installed the package and filled in the values in the config-file, you need to setup model from which you want to take media.

Your Eloquent models should use the `BinBytes\ModelMediaBackup\Traits\HasBackupRecord` trait.

The trait contains an abstract method `backupFiles()` that you must implement yourself.

Here's an example of how to implement the trait:

```
