Downloads
Stars
Version
laravel file manager is a package for
composer require "artincms/laravel_file_manager"
'providers' => [
...,
ArtinCMS\LFM\LFMServiceProvider::class,
]
'aliases' => [
...,
'FileManager' => ArtinCMS\LFM\Facades\FileManager::class,
]
$ php artisan vendor:publish --provider="ArtinCMS\LFM\LFMServiceProvider"
$ php artisan vendor:publish --provider="ArtinCMS\LFM\LFMServiceProvider" --force
$ php artisan migrate
php artisan db:seed --class="ArtinCMS\LFM\Database\Seeds\FilemanagerTableSeeder"
The package will use these optimizers if they are present on your system:
for install this package in your server :
Here's how to install all the optimizers on Ubuntu:
sudo apt-get install jpegoptim
sudo apt-get install optipng
sudo apt-get install pngquant
sudo npm install -g svgo
sudo apt-get install gifsicle
And here's how to install the binaries on MacOS (using Homebrew):
brew install jpegoptim
brew install optipng
brew install pngquant
brew install svgo
brew install gifsicle
for enable optimizer in package you shoul go config/laravel_file_manager.php and set 'Optimise_image'= true
for more information you can visit image-optimizer
LFM_CreateModalFileManager($section, $options , $insert , $callback , $modal_id , $header , $button_id, $button_content)
that $section is Require and other input is optional .for use output of filemanager you should install jquery 3 and bootstrap 4 ;
$options = ['size_file' => 100, 'max_file_number' => 30, 'true_file_extension' => ['png','jpg']];
//the inserted file result is
{
Manager :
available:1,
data :
[{
0 :
{
file :
{
height : "0"
icon : "image"
id : 115
name : "photo2017-04-1512-45-2"
quality : "100"
size : 60187
type : "original"
user : "faramarz"
version : null
width: "0"
},
full_url: "http://127.0.0.1:8000/LFM/DownloadFile/ID/115/original/404.png/100/0/0",
message: "File with ID :115 Inserted",
success:true
url: "/LFM/DownloadFile/ID/115/original/404.png/100/0/0",
full_url_large:"http://127.0.0.1:8000/LFM/DownloadFile/ID/24/small/404.png/100/300/180",
full_url_medium:"http://127.0.0.1:8000/LFM/DownloadFile/ID/24/medium/404.png/100/300/180",
}
}],
view :
{
'list' : 'html grid view code' ,
'grid' : 'html grid view code' ,
'small' :'html small view code' ,
'medium' : 'html thumb view code' ,
'large' : 'html large view code'
}
}
//to show above data to small view you can use this function
function callback(result)
{
$('#show_area_small').html(result.Manager.view.small) ;
}
you can access to file manager with :http://www.yourdomain.com/LFM/ShowCategories
$res = LFM_SaveMultiFile($obj_model, $section, $type , $relation_name , $attach_type)
public function files()
{
return $this->morphToMany('ArtinCMS\LFM\Models\File' , 'fileable','lfm_fileables','fileable_id','file_id')->withPivot('type')->withTimestamps() ;
}
LFM_SaveSingleFile($obj_model, $column_name, $section,$column_option_name)
LFM_CreateModalUpload($section, $callback , $options, $result_area_id , $modal_id , $header , $button_id , $button_content)
$options = ['size_file' => 1000, 'max_file_number' =>5, 'min_file_number' => 2,'show_file_uploaded'=>'medium', 'true_file_extension' => ['png','jpg','zip'],'path'=>'myuploads/sdadeghi'];
for load files (for example you can use this helper functons when you want edit) you can use this helpers function
LFM_LoadMultiFile($obj_model, $section, $type = null, $relation_name = 'files')
LFM_loadSingleFile($obj_model, $column_name, $section, $column_option_name = false)
LFM_ShowMultiFile($obj_model, $type, $relation_name )
LFM_ShowingleFile($obj_model, $column_name, $column_option_name)
LFM_GenerateDownloadLink($type, $id , $size_type, $default_img, $quality , $width, $height)
LFM_GetBase64Image($file_id, $size_type, $not_found_img , $inline_content , $quality , $width , $height )
LFM_GeneratePublicDownloadLink($path,$filename)
if you want to have custom config you can chage config/laravel_file_manager.php file as you want .
in this example we assing zip file and user profile picture to article and save it . at first in Route :
Route::get('/MultiFile', 'HomeController@multiSection')->name('multiSection');
Route::get('/MultiFile/{id}', 'HomeController@multiSectionEdit')->name('multiSectionEdit');
Route::get('/ShowMultiFile/{id}', 'HomeController@showMultiFile')->name('showMultiFile');
Route::post('/StoreArticle', ['as' => 'StoreArticle', 'uses' => 'HomeController@StoreArticle']);
Route::post('/StoreEditArticle', ['as' => 'StoreEditArticle', 'uses' => 'HomeController@StoreEditArticle']);
use ArtinCMS\LFM\Traits\lfmFillable ;
use ArtinCMS\LFM\Models\File;
class Article extends Model
{
use lfmFillable;
}
public function multiSection()
{
$optionsAttach = ['size_file' => 100, 'max_file_number' => 5, 'true_file_extension' => ['zip']];
$option_single = ['size_file' => 100, 'max_file_number' => 1, 'true_file_extension' => ['png','jpg']];
$attach = LFM_CreateModalFileManager('Attach',$optionsAttach , 'insert','showAttach');
$single = LFM_CreateModalFileManager('Single',$option_single , 'insert','showSingle');
return view('multiSection',compact('attach','single'));
}
public function multiSectionEdit($id)
{
$optionsAttach = ['size_file' => 100, 'max_file_number' => 5, 'true_file_extension' => ['zip']];
$option_single = ['size_file' => 100, 'max_file_number' => 1, 'true_file_extension' => ['png','jpg']];
$attach = LFM_CreateModalFileManager('Attach',$optionsAttach , 'insert','showAttach');
$article = Article::find($id);
$load_attch = LFM_LoadMultiFile($article,'Attach','zip','files') ;
$single = LFM_CreateModalFileManager('Single',$option_single , 'insert','showSingle');
$load_single = LFM_loadSingleFile($article,'default_img_file_id','Single');
return view('multiSectionedit',compact('attach','single','load_attch','load_single','article'));
}
public function showMultiFile ($id)
{
$article = Article::find($id);
$show_attch = LFM_ShowMultiFile($article,'zip','files') ;
$show__single = LFM_ShowingleFile($article,'default_img_file_id','Single');
return view('showMultiFile',compact('show_attch','show__single','article'));
}
public function StoreArticle(Request $request)
{
$article = new Article ;
$article->title = $request->title ;
$article->body = $request->body ;
$article->save() ;
$res['Attach'] = LFM_SaveMultiFile($article,'Attach','zip','files' , 'attach');
$res['Single'] = LFM_SaveSingleFile($article,'default_img_file_id','Single','options');
return $res ;
}
public function StoreEditArticle(Request $request)
{
$article =Article::find($request->id);
$res['Attach'] = LFM_SaveMultiFile($article,'Attach','zip','files' , 'sync');
$res['Single'] = LFM_SaveSingleFile($article,'default_img_file_id','Single','options');
return $res ;
}
and in multisection.blade.php
{!! $attach['button'] !!}
{!! $attach['modal_content'] !!}
div#show_area_Attach_list
function showAttach(res) {
$('#show_area_Attach_list').html(res.Attach.view.list) ;
$('#show_area_Attach_grod').html(res.Attach.view.grid) ;
$('#show_area_Attach_small').html(res.Attach.view.small) ;
$('#show_area_Attach_medium').html(res.Attach.view.medium) ;
$('#show_area_Attach_large').html(res.Attach.view.large) ;
}
and in multisectioneditl.blade.php
{!! $attach['button'] !!}
{!! $attach['modal_content'] !!}
div#show_area_Attach {!! $load_attch['view']['list'] !!}
function showAttach(res) {
$('#show_area_Attach').html(res.Attach.view.list,'slider') ;
}