Skip to content

Commit

Permalink
Merge pull request #7 from devuniverse/1.1.2
Browse files Browse the repository at this point in the history
Support to Laravel 7, 8
  • Loading branch information
devuniverse authored Jan 4, 2021
2 parents b8f79ae + c835379 commit 32f2d88
Show file tree
Hide file tree
Showing 44 changed files with 6,591 additions and 211 deletions.
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
{
"name": "Devuniverse",
"email": "[email protected]"
},
{
"name": "Laravrix",
"email": "[email protected]"
}
],
"autoload": {
Expand All @@ -32,11 +36,11 @@
},
"minimum-stability": "stable",
"require": {
"laravel/framework": "5.8.*",
"intervention/image": "2.4",
"codiiv/laravel-taxonomies": "1.0.*"
"codiiv/laravel-taxonomies":"^1.2",
"laravel/framework": "^6.0 || ^7.0 || ^8.0",
"intervention/image": "^2.5"
},
"require-dev": {
"laravel/laravel": "5.8.*"
"laravel/laravel": "^6.0"
}
}
14 changes: 9 additions & 5 deletions src/Config/filemanager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php
return [
/**
*|
*/
"mode" => 'multi',
/**
*|
*/
Expand All @@ -19,15 +23,15 @@
/**
*|
*/
"filemanager_url" => "file-manager",
"filemanager_url" => "{lang}/media",
/**
*|
*/
"master_file_extend" => "filemanager::main",
"master_file_extend" => "layouts.backend",
/**
*|
*/
"files_per_page" => 25,
"files_per_page" => 20,

/**
*| #1 : defaults to public. Like Laravel
Expand All @@ -53,7 +57,7 @@
'yields' => [
'head' => 'css',
'footer' => 'js',
'filemanager-content'=>'filemanager-content'
'filemanager-content'=>'content'
],
/**
*|
Expand All @@ -68,6 +72,6 @@
*|
*/
'separate_uploads' => [

]
];
26 changes: 15 additions & 11 deletions src/Controller/FilemanagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FilemanagerController extends Controller

private $files_upload_path;
private $files_upload_thumb_path;
private $images_path;
private $files_path;
private $images_thumb_path;
private $zips_folder;
private $others_folder;
Expand All @@ -28,13 +28,13 @@ public function __construct()
{
// $this->files_upload_path = storage_path(Config::get('filemanager.files_upload_path'));
$this->default_disk = Config::get('filemanager.filemanager_default_disk');
$this->filemanager_url_protocol=Config::get('filemanager.filemanager_url_protocol');
$this->filemanager_url_protocol= Config::get('filemanager.filemanager_url_protocol');
$this->files_upload_path = Storage::disk(Config::get('filemanager.filemanager_default_disk'))->getAdapter()->getPathPrefix().Config::get('filemanager.files_upload_path');
$this->files_upload_thumb_path = Storage::disk(Config::get('filemanager.filemanager_default_disk'))->getAdapter()->getPathPrefix().Config::get('filemanager.files_upload_thumb_path');
$this->image_extensions = ['jpeg','jpg', 'png', 'gif'];
$this->images_path = 'imgs';
$this->images_thumb_path = 'imgs/thumbnails';

$this->files_path = Config::get('filemanager.files_upload_path');
$this->images_thumb_path = Config::get('filemanager.files_upload_thumb_path');
$this->zips_folder = 'zips';
$this->others_folder = 'others';

Expand Down Expand Up @@ -117,7 +117,7 @@ public function store(Request $request)
});
if($this->default_disk == 's3'){
$streamed = $thumbUploaded->stream();
Storage::disk('s3')->put('uploads/imgs/thumbnails/'.$resize_name , $streamed->__toString(), 'public');
Storage::disk('s3')->put($this->files_upload_thumb_path.'/'.$resize_name , $streamed->__toString(), 'public');
}else{
$thumbUploaded->save($resized);
}
Expand All @@ -134,17 +134,19 @@ public function store(Request $request)

if(self::isImage($extension)){

$filePath = $this->images_path.'/'. $save_name;
$filePath = $this->files_path.'/'. $save_name;
$filePathThumbs = $this->images_thumb_path.'/' . $resize_name;

}elseif(self::isZip($extension)){


$filePath = $this->files_upload_path.'/'.$this->zips_folder.'/'. $save_name;
$filePathThumbs = '';

}else{

$filePath = $this->files_upload_path.'/'.$this->others_folder.'/'. $save_name;
$filePathThumbs = '';

}
$path = 'https://s3.amazonaws.com/'.$bucket.'/'.$filePath;
Expand All @@ -155,8 +157,10 @@ public function store(Request $request)
$s3 = \Storage::disk('s3');
$imageAmazoned = $s3->put($filePath, file_get_contents($file), 'public');

$fileurl = $this->filemanager_url_protocol.'://'.$pathUrl;
$fileurlThumb = $this->filemanager_url_protocol.'://'.$pathUrlThumbs;
// $fileurl = $this->filemanager_url_protocol.'://'.$pathUrl;
// $fileurlThumb = $this->filemanager_url_protocol.'://'.$pathUrlThumbs;
$fileurl = $pathUrl;
$fileurlThumb = $pathUrlThumbs;
}else{

//$this->files_upload_thumb_path
Expand Down Expand Up @@ -233,7 +237,7 @@ public function destroy(Request $request)
/**
* @method deleteFiles
* @param object mixed $request
* @return redirect
* @return redirect
*/
public function deleteFiles(Request $request){
$requested = $request->POST;
Expand Down
3 changes: 3 additions & 0 deletions src/FilemanagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ public function boot()

view()->composer('*', function ($view){
$request = Request();
$view->with('alluploads', Models\Upload::paginate(20));

if(\Auth::check()){



};
});
}
Expand Down
31 changes: 31 additions & 0 deletions src/Models/Filemanager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Devuniverse\Filemanager\Models;

use Illuminate\Database\Eloquent\Model;

class Filemanager extends Model
{
/**
* This allows to create a custom input field, to launch modal upload
* @param customId
* @param module
* @param uniqueTo
* @param placeholder
*/
static public function customTextInput($customId, $module='',$uniqueTo=null,$placeholder ='', $type="input"){
switch ($type) {
case 'button':
$html = '<div class="custominput-container">'.
'<button type="button" class="form-control uploadunique" id="'.$customId.'" '.($uniqueTo ? 'data-uniqueto="'.$uniqueTo.'"' : '').' '.($module!="" ? 'data-module="'.$module.'"' : '').'>'.$placeholder.'</button>'.
'</div>';
break;
default:
$html = '<div class="custominput-container">'.
'<input type="text" class="form-control uploadunique" id="'.$customId.'" placeholder="'.$placeholder.'" '.($uniqueTo ? 'data-uniqueto="'.$uniqueTo.'"' : '').' '.($module!="" ? 'data-module="'.$module.'"' : '').' value="">'.
'</div>';
break;
}
return $html;
}
}
10 changes: 10 additions & 0 deletions src/Routes/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$filemanagerPath = Config::get('filemanager.mode')=='multi' ? '{global_entity?}/'.Config::get('filemanager.filemanager_url') : Config::get('filemanager.filemanager_url');

Route::group(['prefix' => $filemanagerPath, 'middleware' => ['web','auth']], function()
{

include('web.php');

});
33 changes: 16 additions & 17 deletions src/Routes/web.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php

$filemanagerPath = Config::get('filemanager.filemanager_url');
/**
* GET ROUTES
*/
Route::get('/', 'Devuniverse\Filemanager\Controllers\FilemanagerController@loadIndex');
Route::get('create', 'Devuniverse\Filemanager\Controllers\FilemanagerController@create')->name('filemanager.create');
Route::get('showfiles', 'Devuniverse\Filemanager\Controllers\FilemanagerController@index')->name('load.filemanager.index');
Route::get('modaluploader', 'Devuniverse\Filemanager\Controllers\FilemanagerController@loadGallery')->name('load.filemanager.gallery');
Route::get('modalcropper', 'Devuniverse\Filemanager\Controllers\FilemanagerController@getModalCropper');

Route::group(['prefix' => $filemanagerPath, 'middleware' => ['web','auth']], function()
{
/**
* GET ROUTES
*/
Route::get('/', 'Devuniverse\Filemanager\Controllers\FilemanagerController@loadIndex');
Route::get('create', 'Devuniverse\Filemanager\Controllers\FilemanagerController@create')->name('filemanager.create');
Route::get('showfiles', 'Devuniverse\Filemanager\Controllers\FilemanagerController@index')->name('load.filemanager.index');

Route::post('/file-save', 'Devuniverse\Filemanager\Controllers\FilemanagerController@store');
Route::post('/file-delete', 'Devuniverse\Filemanager\Controllers\FilemanagerController@destroy');
Route::post('/delete-files', 'Devuniverse\Filemanager\Controllers\FilemanagerController@deleteFiles');
Route::post('/file-save', 'Devuniverse\Filemanager\Controllers\FilemanagerController@store');
Route::post('/file-delete', 'Devuniverse\Filemanager\Controllers\FilemanagerController@destroy');
Route::post('/delete-files', 'Devuniverse\Filemanager\Controllers\FilemanagerController@deleteFiles');

/**
* POST ROUTES
*/

});
/**
* POST ROUTES
*/
Route::post('/modaluploader', 'Devuniverse\Filemanager\Controllers\FilemanagerController@modalUploader');
Route::post('/modalcropper', 'Devuniverse\Filemanager\Controllers\FilemanagerController@modalCropper');
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddUniqueToColumnToUploadsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasColumn('uploads', 'uniqueto')){
Schema::table('uploads', function (Blueprint $table) {
$table->string('module')->default('')->after('file_url');
$table->string('uniqueto')->default('')->after('module');
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (Schema::hasColumn('uploads', 'uniqueto')){
Schema::table('uploads', function (Blueprint $table) {
$table->dropColumn('module');
$table->dropColumn('uniqueto');
});
}
}
}
Loading

0 comments on commit 32f2d88

Please sign in to comment.