Использование только маршрута:
Route::any('/article/images/{id}', ['as' => 'article.image', function($id) {
$article = Article::find($id);
$images = explode(',',$article->images);
return Response::download($images[0]);
}]);
Использование контроллера:
namespace MyNamespace;
use Illuminate\Routing\Controller;
use App\Article;
use Response;
class ImagesController extends Controller
{
public function show($id)
{
$article = Article::find($id);
$images = explode(',',$article->images);
return Response::download($images[0]);
}
}
Ваш маршрут:
Route::get('/article/images/{id}', ['as' => 'article.image', 'uses' => 'MyNamespace\ImagesController@show']);
Тогда по вашему мнению:
<img src="{{route('article.image', ['id' => $article->getKey()])}}" />
Так что ваш взгляд будет выглядеть так:
@foreach($articles as $article)
<div class="article_wrapper">
<div class="article_body">
<img src="{{route('article.image', ['id' => $article->getKey()])}}" />
</div>
</div>
@endforeach
Если вы не сохраняете полный путь в поле изображений, добавьте к нему префикс:
return Response::download('C:\downloadpath\' . $images[0]);