我们有一个用旧 PHP 编写的业务后端,我们现在想尝试在 Laravel 中重做它,但在跳转时遇到了问题。
我已经阅读了大量教程,但似乎很难找到相关的教程。我们有一个充满记录的数据库,对于第一页,我们只想将它们全部打印到一个表中。
在常规 php 中,我们只运行一个查询,将其放入一个数组并解析出数据。我尝试在视图控制器中这样做,但收效甚微......
表格格式可能会略微偏离,只是暂时尝试打印数据,路线和一切正常。
如果一切都设置在理想的地方,或者这是否是理想的方式,我不是 100%,但这是我们所拥有的:
在此先感谢您的帮助!
// Model:'PaymentInfo' - Database Table: 'payment_info'
Class PaymentInfo extends Eloquent
{
public $connection = 'main';
protected $table = 'payment_info';
protected $primaryKey = 'order_id';
public function getLastname()
{
return $this->lastname;
}
public function getFirstname()
{
return $this->firstname;
}
public function getBuyerEmail()
{
return $this->buyer_email;
}
public function getCountry()
{
return $this->country;
}
public function getMcGross()
{
return $this->mc_gross;
}
然后控制器:
class AdminController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getIndex()
{
return View::make('admin.index');
}
}
最后是观点:
@extends('master')
@section('content')
<div class="span 8 well">
<h4>Hello {{ (Auth::user()->username) }}</h4>
</div>
<div>
<div style="font-size:medium">
<h1>
<center>Recent Orders</center>
</h1>
</div>
<div id="highstyle1">
<table border="1" cellspacing="0" cellpadding="4">
<tr>
<th>Order #</th>
<th>Buyer Name</th>
<th>Email Address</th>
<th>Country</th>
<th>Payment</th>
<th>Buyer Memo</th>
<th>Order Date</th>
<th>Status</th>
<th>Transaction ID</th>
</tr>
<tr>
{{ $order_id = PaymentInfo::all() }}
@foreach ($order_id as $order)
<td>{{ PaymentInfo::$order->lastname }}</td>
@endforeach
</tr>
</table>
</div>
</div>
@stop