Preparing a future frontcontroller for accessing media

parent 8c37d199
<?php
namespace Modules\Media\Http\Controllers\Frontend;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use Modules\Media\Repositories\FileRepository;
class MediaController extends Controller
{
/**
* @var FileRepository
*/
private $file;
public function __construct(FileRepository $file)
{
$this->file = $file;
}
public function show($path)
{
$file = $this->file->findForVirtualPath($path);
$type = $file->mimetype;
$path = storage_path('app' . $file->path->getRelativeUrl());
return Image::make($path)->response();
return response()->file($path, [
"Content-Type:$type"
]);
}
}
<?php
use Illuminate\Routing\Router;
/** @var Router $router */
//$router->get('assets/newmedia/{path}', [
// 'as' => 'public.media.media.show',
// 'uses' => 'Frontend\MediaController@show',
//]);
......@@ -17,7 +17,7 @@ class RouteServiceProvider extends CoreRoutingServiceProvider
*/
protected function getFrontendRoute()
{
return false;
return __DIR__ . '/../Http/frontendRoutes.php';
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment