PHP code example of codebuglab / laravel-media-removable

1. Go to this page and download the library: Download codebuglab/laravel-media-removable 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/ */

    

codebuglab / laravel-media-removable example snippets


use CodeBugLab\MediaRemovable\MediaRemovable;

class MyModel extends Eloquent
{
    use MediaRemovable;

    private static $mediaFields = ['image']; //image is column_name you want to delete

}
 

use CodeBugLab\MediaRemovable\MediaRemovable;

class MyModel extends Eloquent
{
    use MediaRemovable;

    private static $mediaFields = ['image']; //image is column_name you want to delete

    private static $mediaPath = "storage/app/public/"; //The path of you media files
}

use CodeBugLab\MediaRemovable\MediaRemovable;

class MyModel extends Eloquent
{
    use MediaRemovable;

    // set all columns and paths for this model
    public static $mediaDetails = [
        [
            'field' => 'image',
            'path' => 'storage/app/public/images/'
        ],
        [
            'field' => 'profile_picture',
            'path' => 'storage/app/public/profile/'
        ],
    ];
}

use CodeBugLab\MediaRemovable\MediaRemovable;

class MyModel extends Eloquent
{
    use MediaRemovable;
}

return [
    'path' => 'storage/app/public/',

    'fields' => ['image']
];

return [
    'details' => [
        'table_name' => [
            [
                'field' => 'field_name',
                'path' => 'storage/app/public/directory/'
            ],
            [
                'field' => 'another_field_name',
                'path' => 'storage/app/public/another_directory/'
            ]
        ], 
        'another_table_name' => [
            [
                'field' => 'image',
                'path' => 'storage/app/public/'
            ]
        ]
    ]
];
bash
php artisan vendor:publish --provider="CodeBugLab\MediaRemovable\MediaRemovableServiceProvider"