2
我们有一个后端为我们的业务用良好的旧PHP编写,我们现在想尝试在Laravel中重做它,但有问题跳跃。通过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
我做了更改,现在的东西肯定更有意义,但它给出了“没有收到数据,错误代码:ERR_EMPTY_RESPONSE”的错误。我从我的模型中遗漏了什么? – Nick8675
看看你的Web服务器日志,你应该会看到一些错误。 –
宾果,就是这样。谢谢! – Nick8675