32 lines
700 B
PHP
32 lines
700 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
class ImagesController extends Controller
|
|
{
|
|
public function show(Request $request, string $file)
|
|
{
|
|
try {
|
|
return response()->file($this->imagePath($file));
|
|
} catch (\Exception $e) {
|
|
abort(404);
|
|
}
|
|
}
|
|
|
|
public function subDirectory(Request $request, string $directory, string $file)
|
|
{
|
|
try {
|
|
return response()->file($this->imagePath("{$directory}/{$file}"));
|
|
} catch (\Exception $e) {
|
|
abort(404);
|
|
}
|
|
}
|
|
|
|
private function imagePath(string $file): string
|
|
{
|
|
return resource_path('images/'.$file);
|
|
}
|
|
}
|