There is a need to dynamically include files, how can I get this code to work in Laravel?

@include('template.information_page' . $row->template_path) 

    1 answer 1

    Everything is working. Here is:

    Template:

     <body> @include('random'.$data['randomBlade']); </body> 

    Controller:

     class HomeController extends Controller { public function index() { $data = [ 'randomBlade' => rand(0, 2) ]; return view('pages.messages.index') ->withData($data); } } 

    random0.blade.php:

     <h1>random0</h1> 

    random1.blade.php:

     <h1>random1</h1> 

    random2.blade.php:

     <h1>random2</h1>