2017-05-16 9 views
0

私の詳細の出力を表示する方法。自分のコードや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'); 
    } 
} 

私はそれにモーダルを使用しています。この1。

Index.blade.php - 詳細

@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('[email protected]', $rental->id) }}">Edit</a></td> 
        <td> 
         @include('detail.delete') 
        </td> 

        @endforeach 
       </tr> 

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



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


@endsection 

私はあなたがこれで私を助けることができると思います。 ありがとうございます。

答えて

0

多くの間違いや関連するテーブルに関する情報が不十分です。

  • 閉じる</tr>あなたがテーブルでは使用できません$detail->total_amountを使用価格については@endforeach
  • 前に、$detail->price
  • をする必要がありますモーダルはクロージング5 </div>
  • をモーダル内部取引の詳細をしている欠けていますすべての変数が混在しています
  • 変数$rentalは定義されていませんが、詳細の取得に使用されています
関連する問題