Reputation: 73
This is my code in laravel blade
@foreach($modules as $module) // {{ mod.$module['module_name'] }}
giving me right value
@section('content')
@include("mod.$module['module_name']") // mod is my folder name and
$module['module_name'] value is
coming from database
@endsection
@endforeach
{{ mod.$module['module_name'] }} is giving me correct value but when i pass it to @include it gives me error. Please help me !!!
Upvotes: 1
Views: 1714
Reputation: 2030
I think it has to do with the way the blade template translates the @include directive into compiled PHP. Including the snippet from the compiled PHP file would help, but try this:
@include( 'mod.' . $module['module_name'] )
Looking at some of my past code, you can definitely use a variable in an include. In my case I simply built the desired filename in the controller and passed it along to the view, so my include statement was simply:
@include( $filename )
Upvotes: 3