它不会显示我的详细信息的输出

时间:2017-05-16 02:41:07

标签: php laravel

如何显示我的详细信息的输出。我的代码或Laravel的数据库中是否有问题。

数据库

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDetailsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('details', function (Blueprint $table) {
            $table->increments('id');
            $table->text('price');
            $table->text('quantity');
            $table->timestamp('returned_at');
            $table->timestamps();

            $table->integer('video_id')->unsigned();
            $table->foreign('video_id')
                ->on('videos')
                ->references('id')
                ->onUpdate('cascade')
                ->onDelete('restrict');

            $table->integer('transaction_id')->unsigned();
            $table->foreign('transaction_id')
                ->on('rentals')
                ->references('id')
                ->onUpdate('cascade')
                ->onDelete('restrict');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('details');
    }
}

这个我正在使用莫代尔。

Index.blade.php - detail

@section('content')
<html>
        <head>
    <div class="row">
        <h1 class="page-header">Details</h1>
        <div class="col-md-12">

        <table class="table">
        <thead>
            <tr>
                <th>Video ID</th>
                <th>Price </th>
                <th>Returned at</th>
                <th>View</th>
                <th>Edit</th>
                <th>Delete</th>
            </tr>
            </thead>
            <tbody>
                @foreach($details as $x => $detail)
                <tr>
                    <td>{{ $detail->video_id }}</td>
                    <td>{{ $detail->total_amount }}</td>
                    <td>{{ $detail->returned_at }}</td>
                    <td><button type="button" class="btn btn-info" data-toggle="modal" data-target="#viewren{{ $x }}">View</button>

                    <div id="viewren{{ $x }}" class="modal fade" role="dialog">
              <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                   <h1 class="page-header">Transaction: {{$detail->id}}</h1>

                  <center><div class="modal-body">

            <div class="row">
                <div class="col-md-12">

                <dl class="dl-horizontal">

                    <dt>ID:</dt><dd>{{ $detail->video_id }}</dd>
                    <dt>Rented at:</dt><dd>{{ $detail->price }}</dd>
                    <dt>Total Amount:</dt><dd>{{ $detail->quantity }}</dd>
                    <dt>Interest Amount:</dt><dd>{{ $detail->status }}</dd>
                    <dt>Interest Amount:</dt><dd>{{ $detail->returned_at }}</dd>
                    </dl>

                </div>
            </div>

            <div class="row">
                <div class="col-md-12">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <td>Video</td>
                                <td>Status</td>
                                <td>Returned Date</td>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($rental->details as $v)
                            <tr>
                                <td>{{ $v->video->title }}</td>
                                <td>{{ $v->status }}</td>
                                <td>{{ $v->returned_at }}</td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>

                    </td>
                    <td><a class="btn btn-primary" href="{{ action('RentalController@edit', $rental->id) }}">Edit</a></td>
                    <td>
                        @include('detail.delete')
                    </td>

                    @endforeach
                </tr>

                <div class="parallax"></div>
            </tbody>
        </thead>



        </table>
        </div>
        </div>


@endsection

我希望你能帮助我。 谢谢你的回答。

1 个答案:

答案 0 :(得分:0)

我可以找到太多关于相关表格的错误和信息不足。

  • </tr>
  • 之前关闭@endforeach
  • 对于您使用$detail->total_amount的价格,表格中不可用,$detail->price
  • 模式缺失5关闭</div>
  • 模态内的交易详情已全部混淆变量
  • 变量$rental尚未定义,但用于获取详细信息