gemadigital / file-manager
Gema Digital File Manager
Installs: 391
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Language:JavaScript
Requires
- php: ^7.4|^8.0|^8.1
- illuminate/support: ~7|~8|~9
Requires (Dev)
- orchestra/testbench: ~5|~6
- phpunit/phpunit: ~9.0
- dev-master
- 0.28
- 0.24
- 0.23.9
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1
- 0.0.34
- 0.0.33
- 0.0.32
- 0.0.31
- 0.0.30
- 0.0.29
- 0.0.28.2
- 0.0.28.1
- 0.0.28
- 0.0.27.4
- 0.0.27.2
- 0.0.27.1
- 0.0.27
- 0.0.26
- 0.0.25.3
- 0.0.25.2
- 0.0.25.1
- 0.0.25
- 0.0.24
- 0.0.23.11
- 0.0.23.10
- 0.0.23.9
- 0.0.23.8
- 0.0.23.7
- 0.0.23.6
- 0.0.23.5
- 0.0.23.4
- 0.0.23.2
- 0.0.23.1
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20.1
- 0.0.20
- 0.0.19.3
- 0.0.19.2
- 0.0.19.1
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.2
- 0.0.1
This package is auto-updated.
Last update: 2024-11-29 20:09:28 UTC
README
This is where your description should go. Take a look at contributing.md to see a to do list.
Installation
Via Composer
composer require gemadigital/file-manager
Usage
Running migrations
php artisan migrate
Publishing the config
php artisan vendor:publish --provider="GemaDigital\FileManager\FileManagerServiceProvider"
Sample config file
<?php use App\Models\Project; return [ 'parents' => [ Project::class, // Parent classes namespaces (multiple parents supported) ], // Parent field should appear or should be infer // You may use a closure to define the access to this 'parents_field' => (function () { // return user()->hasManyProjects(); return true; }), // Use to filter the parents list // You may use a closure to define the access to this 'parents_filter' => (function ($query){ if(!admin()) { return $query->whereIn('id', user()->parentsIds()); } return $query; }), 'filter' => (function($query){ /** * Function used in medias fetch operation. * Use to apply filters, ordering, etc to the file-manager medias listing */ if(!admin()){ return $query ->whereIn('parent_id', backpack_user()->projects()) ->where('parent_type', Project::class); } return $query; }) // Menu // You may use a closure to define the access on CRUD 'access' => [ 'file-manager' => true, 'media-tag' => true, 'media-type' => true, 'media-version' => true, ], // Use media cloud or use Laravel Storage // Set as false to use media cloud, set a diskname to use Laravel Storage 'disk' => false, ];
Adding File-Manager to the sidebar menu
sidebar_content.blade.php
@include('file-manager::sidebar_content')
Using File-Manager as a field (associated to an entity)
MyEntity.php
<?php use GemaDigital\FileManager\app\Models\Traits\MediaTrait; use GemaDigital\Framework\app\Models\Model; class MyEntity extends Model { use MediaTrait; // Use the trait protected static $mediable = ['images', 'videos']; // Define which columns will have medias }
MyEntityCrudController.php
<?php class MyEntityCrudController extends CrudController { public function setupCreateOperation(){ // Setting up the fields $this->crud->addField([ 'name' => 'images', 'type' => 'file-manager', 'view_namespace' => 'file-manager::field', 'media_type' => 1 // Get this from `media_types.id` ]); $this->crud->addField([ 'name' => 'videos', 'type' => 'file-manager', 'view_namespace' => 'file-manager::field', 'media_type' => 2 // Get this from `media_types.id` ]); } }
Using File-Manager as a Vuejs Component
Install dependencies for Vue.js
File-manager uses select2, but this cannot be installed on the fly, so you will need to do it manually, the easiest way is to include their CDN in your HTML:
index.html
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
MyComponent.vue
<template> <div> <FileManager name="fieldName" mediaType="1" min="1" max="1" triggerClasses="btn btn-primary" @save="onSave" > <!-- Trigger Template (sample) --> <template v-slot:trigger> My trigger </template> <!-- Selected Media Template (sample) --> <template v-slot:selectedMedia="slot"> <!-- slot property holds all the data from the media --> <img class="w-100" :src="slot.media.media_content.preview"/> </template> </FileManager> </div> </template> <script> // Import FileManager component import FileManager from "../../../../vendor/gemadigital/file-manager/src/resources/js/vue/FileManager.vue"; export default { components:{ FileManager, }, methods: { // Define what happens when medias are selected onSave(selectedMedias){ console.log('Do something with' , {selectedMedias}); } }, }; </script>
Change log
Please see the changelog for more information on what has changed recently.
Testing
composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author@email.com instead of using the issue tracker.
License
MIT. Please see the license file for more information.