How does laravel get an array?
给我你的怀抱
给我你的怀抱 2017-05-16 16:55:14
0
2
522
路由器写法:

Route::get('/', function () {


   $db=[
     'id'=>1,
     'name'=>'ok'

   ];

    return view('welcome',$db);
});


weclome template:

    @foreach($db as $v)           
             {{ $v->id }}
          @endforeach

Error report:

ErrorException in 09a920b7dfeb8f66040a471f4982c97d line 42: Undefined variable: db (View: K:\demo\resources\views\welcome.blade.php)

why is that?

给我你的怀抱
给我你的怀抱

reply all(2)
習慣沉默

return view('welcome',['db' => $db]);

大家讲道理
@foreach ($welcome as $v)
    {{ $v->id }}
@endforeach
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template