Search code examples
phplaravellaravel-5laravel-bladelaravelcollective

How to use "laravelcollective/html" with blade


I'm trying to pull data from folder so that a user can download it I'm trying something like this

{!! Html::link('public/{{$file->name}}', '{{$file->name}}') !!}

but it throws out this

 <?php echo e($file->name); ?>
 <?php echo e($file->name); ?>

Is it possible to combine those two and how can it be done

Controller part

public function download($file_name){
    $file_path = public_path('/'.$file_name);
    return response()->download($file_path);
}

It calls this error

NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 821
at Router->findRoute(object(Request)) in Router.php line 691

User will need to be able download different kind of files img/pdf/doc/xls.


Solution

  • You don't nest blade within blade. You just do it once.

    {!! Html::link('public/'.$file->name, $file->name) !!}
    

    Blade will handle the parsing from there.