Exemplo n.º 1
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $url = $request->getPathInfo();
     if (strpos('/backend', $url) === false) {
         if (substr($url, 0, 9) === "/download") {
             $path = Config::get('filesystems.disks.local.root', storage_path() . '/app');
             $file = $path . str_replace(["/download", "storage/app/"], "", urldecode($url));
             if (file_exists($file) && is_file($file)) {
                 return response()->download($file);
             }
         } elseif ($url !== "/") {
             $url = Post::checkUrl($url);
         }
     }
     return App::make('Cms\\Classes\\Controller')->run($url);
 }
Exemplo n.º 2
0
<?php

use Bm\Field\Models\Post;
// pobieranie plików
Route::group(['prefix' => 'download'], function () {
    Route::get('{name}', function ($name) {
        $path = Config::get('filesystems.disks.local.root', storage_path() . '/app');
        $file = $path . str_replace("storage/app/", "", urldecode($name));
        if (is_file($file)) {
            return response()->download($file);
        }
    })->where('name', '.*');
});
// artykuły i kategorie
Event::listen('cms.route', function () {
    Route::any('{slug}', function ($slug) {
        return (new Cms\Classes\CmsController())->run(Post::checkUrl("/{$slug}"));
    })->where('slug', '(.*)?');
});