How to use @include with variables in blade in Laravel 5.3?

时间:2016-12-09 12:41:04

标签: laravel-5.3

list.blade.php

<?php
$categories=[
'1'=>'cat1',
'2'=>'cat2',
'3'=>'cat3',
    ];
?>

index.blade.php

@extends('layouts.app')

@section('content')

@include('partials.list')


<?php 
  foreach($categories as $key => $value) 
  { 
     echo "$value <br />"; 
  } 
?>  

@endsection

How to use $categories in index.blade.php? Why @include('partials.list') is not working? Thanks!

0 个答案:

没有答案