Skip to content

Restrict Access To Path

Muah edited this page Nov 28, 2019 · 9 revisions

let's say you have this structure

root "/"
  |_users
    |_admin
      |_pdfs
        |_billings
    |_testing
  |_clients
  |_others

and you want to allow access to only pdfs, so the params would be

@include('MediaManager::_manager', ['restrict' => [
    'path' => 'users/admin/pdfs', 
    'uploadTypes' => ['image/*', 'application/pdf'], // mime-types
    'uploadSize' => 5 // in MB
]])
  • all the params are optional, so you can use only what u need.
  • the uploadTypes param have to be an array of items not a string.

User Example

  • in user model
// ...

class User extends Authenticatable
{
    // ...

    public static function boot()
    {
        parent::boot();

        $disk = app('filesystem')->disk(config('mediaManager.storage_disk'));

        static::created(function ($model) use ($disk) {
            $disk->makeDirectory('users/' . $model->id);
        });

        static::deleted(function ($model) use ($disk) {
            $disk->deleteDirectory('users/' . $model->id);
        });
    }
}
<div v-if="inputName">
    @include('MediaManager::extras.modal', ['restrict' => [
        'path'        => "users/$user->id", 
        'uploadTypes' => ['image/*'], 
        'uploadSize'  => 2
    ]])
</div>

Notes

when the path param is used

  • disable
    • global search

when uploadTypes or uploadSize is used

  • disable
    • upload from url