在Laravel中查看DB结果

时间:2017-08-10 11:45:48

标签: database variables laravel-5 undefined

我正在开发一个Laravel项目,当我尝试将数据库输出到刀片模板时,我一直收到未定义的变量。 DB使用伪数据播种。当用户登录时,应该重定向到查询刀片,然后显示来自db

的数据
 <?php

Route::get('/', function () {
return view('welcome');
});

Route::get('home', function (){
return View::make('home');
});


Route::get('example', function(){
return View::make('example');
});

 Route::get('enquiries', function (){
 return View::make('enquiries');
 });

  Route::get('login', array('uses' => 'HomeController@showLogin'));

 // route to process the form
 /*Route::post('login', array('uses' => 'HomeController@doLogin'));*/


 /*Route::get('admin', function () {
 //brings Auth method into action
 })->middleware('auth');*/




 Auth::routes();

 Route::get('/', 'HomeController@index')->name('welcome');

 Auth::routes();

 Route::get('/home', 'HomeController@index')->name('home');

这是刀片模板代码

@extends('layouts.layout')

@section('content')
<div class="container" id="database" name="database">
    <div class="row white">
        <br>
        <h1 class="centered">Customer Enquiries</h1>
        <hr>

        <div class="col-lg-6">
                <h3>Customer Table</h3>
                 @foreach ( $customer as $customer)

                <!--Display customers table-->
                <h2>{{ $customer->custID }} <small>{{ $customer->name }}: {{ $customer->number }}:{{ $customer->email }}: {{ $customer->comments }}:{{ $customer->bookingID }}</small></h2>
                @endforeach

                <!-- Display bookings table -->
                <h3>Booking Table</h3>
                @foreach ($bookings as $booking)
                    <p>{{ $booking->bookingID }}:{{ $booking->custID }}:{{ $booking->productID }}</p>
                @endforeach

                <!-- Display Products table -->
                <h3>Products Table</h3>
                @foreach($products as $product)
                <p>{{ $product->productID }}:{{ $product->name }}:{{ $product->description }}</p>
                @endforeach
        </div><!-- col-lg-6 -->
<!-- col-lg-6 -->
    </div><!-- row -->
</div>
@endsection

我看了很多不同的帖子,看起来很简单,可以显示数据,但是我无法让它工作。

0 个答案:

没有答案