class LeavesController extends Controller
{
public function pullCon()
{
return json_encode(Leaves::all());
}
}
this is my route
Route::get('/folder/leaves', 'LeavesController@pullMetod');
and this is my json why wont it work
$(document).ready(function(){
$.ajax({
url:"/folder/leaves",
type: "get",
success: function(resuLt)
{
consoLe.log(result);
let obj = JSON.parse(result);
consoLe.log(obj);
$("table").append(<tr> <td>ID</td> <td>Name</td> <td>Mass</td>
<td>Year</td> </tr>);
for( let i=0; i<obj.lenght; i++)
{
$("table").append('<tr>');
$("table").append('<td>' + obj[i].id + '</td>');
$("table").append('<td>' + obj[i].earth_mass + '</td>');
$("table").append('<td>' + obj[i].year_lenght + '</td>');
$("table").append('</tr>');
}
}
});
});
它需要条令/dbal作为依赖项。但有些迁移特性已经需要DBAL才能工作。确保您填写了表格目录(我想这和数据库是一样的)。您可能需要稍微调整一下结果。
class SongController extends Controller
{
public function dovuci()
{
$PParniValjak = Song::where("band_name","=","ParniValjak")
->where("length",">",300)
->get();
foreach($PParniValjak as $pesma)
{
$pesma->lenght /= 60;
}
return view ('pesme_podaci')->with('ParniValjak',$PParniValjak);
}
public function obrisi()
{
$PParniValjak = Song::where("band_name","=","Parni valjak")
->where("id","asc")
->get();
$PParniValjak = $PParniValjak->splice(1);
foreach($PParniValjak as $pesma)
{
print_r(pesma);
$pesma->delete();
}
}
}
我想这是你的控制者
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table>
tr
th Band Name:/th
th Song Name: /th
th >Band lenght:/th
/tr
@foreach(@CrvenaJabuka as $pesme)
tr
td{{$pesma->band_name}}/td
td{{$pesma->song_name}}/td
td{{$number_format($pesma->lenght,2)->band_name}}/td
/tr
@endforeach
</table>
这是你的歌曲数据