1. Go to this page and download the library: Download crip-laravel/filesys 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/ */
...
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
Route::pattern('crip_file', '[a-zA-Z0-9.\-\/\(\)\_\% ]+');
Route::pattern('crip_folder', '[a-zA-Z0-9.\-\/\(\)\_\% ]+');
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapPackageRoutes();
}
/**
* Define the "package" routes for the application.
*/
protected function mapPackageRoutes() {
Route::prefix('packages')
->group(base_path('routes/package.php'));
}
...
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
/**
* Class RegisterUserStorageFolder
* @package App\Http\Middleware
*/
class RegisterUserStorageFolder
{
/**
* Handle an incoming request.
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (!Auth::guard($guard)->check()) {
return redirect('/login');
}
if (!Auth::user()->isAdmin()) {
// For users who is not in group of administrators set their own
// folder for manager and make impossible to see/change files of
// other users.
Config::set('cripfilesys.user_folder', Auth::user()->slug());
}
return $next($request);
}
}
/**
* The application's route middleware.
* These middleware may be assigned to groups or used individually.
* @var array
*/
protected $routeMiddleware = [
...
'user.storage' => \App\Http\Middleware\RegisterUserStorageFolder::class,
];