2016-11-10 8 views
2

私はナビゲーションバーを持つウェブサイトを持っています(main.blade.phpにあります)。私はjQueryテーブルを作成しましたが、ブレードビューではなく単純な.phpとして作成しました。コンテンツセクションを設定してブレードに追加するにはどうすればよいですか?ありがとう!簡単な.phpから.blade.phpにjQueryテーブルを追加するLaravel5

ルート:

web.php

古い(ブレードからの単純なページ):

Route::get('/manageclasses', ['as' => 'manageclasses', 'uses' => 'UserView\[email protected]']); 

新しいもの(テーブルと単純なページ):

Route::get('/manageclasses',['as' => 'manageclasses',function(){ 
    $manageclasa = App\Elevi::all(); 
    return View::make('table')->with('manageclasa', $manageclasa); 
}]); 

テーブルを追加するブレードレイアウト

@extends('layouts.master') 
@extends('layouts.navbar') 
@extends('layouts.sidebar') 


@section('content') 
<h3 class="white-text">Manage Page</h3> 

@endsection 

テーブル

<!doctype html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8"> 
     <title>Manage Clasa</title> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
     <script src="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> 
     <link rel="stylesheet" type="text/css" href="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css"> 
    </head> 


    <body> 
     <h1>Elevi clasa</h1> 
     <table> 
     <thead> 
     <tr> 
      <th>Nume</th> 
      <th>Prenume</th> 
     </tr> 
     </thead> 
     <tbody> 
     <?php foreach ($manageclasa as $elev): ?> 
     <tr> 
      <td><?php echo $elev['nume'] ?></td> 
      <td><?php echo $elev['prenume'] ?></td> 
     </tr> 
     <?php endforeach; ?> 
     </tbody> 
     </table> 

     <script> 
     $(function(){ 
      $("table").dataTable(); 
     }); 
     </script> 
    </body> 
</html> 
+0

問題はここ何ですか? –

+0

テーブルにブレードを追加できません。私はいくつかの方法で試しましたが、成功しませんでした –

+0

私はそれを作る方法をsugestionが必要です –

答えて

0

あなたが雄弁オブジェクトを返していると私の新しいレイアウト。これを試してみてください:

<!doctype html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>Manage Clasa</title> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script src="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> 
<link rel="stylesheet" type="text/css" href="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css"> 
</head> 


<body> 
<h1>Elevi clasa</h1> 
<table id="elevi-clasa"> 
<thead> 
<tr> 
    <th>Nume</th> 
    <th>Prenume</th> 
</tr> 
</thead> 
<tbody> 
@foreach($manageclasa as $elev) 
<tr> 
    <td>{{ $elev->nume }}</td> 
    <td>{{ $elev->prenume }}</td> 
</tr> 
@endforeach 
</tbody> 
</table> 

<script> 
$(function(){ 
$("#elevi-clasa").dataTable(); 
}); 
</script> 
</body> 
</html> 
+1

元の '<?php foreach($ manageclasa as $ elev)は必要ありません:?>' – SCRATK

+0

フィードバックありがとうございます。あなたが正しい。私は余分なforeach行を削除しました。 –

関連する問題