因此,我目前正在进行一个项目,在该项目中,我有一个表,显示了经理的概述以及他们被分配到的当前具有特定状态的应用程序的数量。我想做的是,当用户点击一个数字(即计数)时,它会返回一个列表视图,该视图仅从数据库中查询分配给该经理和该状态的应用程序。否则,如果用户转到应用程序视图,它应该显示所有应用程序。
以下是我的概览视图的代码:
<table class="table tablesorter" id="tblAffs">
<thead>
<tr class="tblhead">
<th>AM</th>
<th>Qualified Prospect</th>
<th>Unqualified Prospect</th>
<th>Contacted</th>
<th>Converted To Account</th>
<th>Pending Integration</th>
<th>Revenue Generating</th>
</tr>
</thead>
<tbody>
@foreach ($totalCount as $id => $name) {{-- id is the admin id --}}
@foreach($name as $n => $status) {{-- $n is the name, $status is array of the counts --}}
<tr>
<td>
{{$n}}
<br>
<a href="#">Closed</a>
</td>
<td><a href="/ap1/{{$new_lead}}/applications?status=2">{{ isset($status[2]) ? $status[2] : 0 }}</a></td>
<td><a href="/ap1/{{$new_lead}}/applications?status=1">{{ isset($status[1]) ? $status[1] : 0 }}</a></td>
<td><a href="/ap1/{{$new_lead}}/applications?status=3">{{ isset($status[3]) ? $status[3] : 0 }}</a></td>
<td><a href="/ap1/{{$new_lead}}/applications?status=4">{{ isset($status[4]) ? $status[4] : 0 }}</a></td>
<td><a href="/ap1/{{$new_lead}}/applications?status=5">{{ isset($status[5]) ? $status[5] : 0 }}</a></td>
<td><a href="/ap1/{{$new_lead}}/applications?status=6">{{ isset($status[6]) ? $status[6] : 0 }}</a></td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
在我的控制器上,这是代码和如何创建数据结构:
public function overview()
{
$query= DB::table('admins')
->join('advertiser_applications', 'admins.id', '=', 'advertiser_applications.assigned_to')
->selectRaw('advertiser_applications.status, admins.id, admins.first_name, COUNT(advertiser_applications.status) count')
->groupBy('admins.id', 'advertiser_applications.status');
$counts = $query->get();
$totalCount = [];
foreach($counts as $count){
$totalCount[$count->id][$count->first_name][$count->status] = $count->count;
}
return View::make('admin.crm.overview', ['totalCount' => $totalCount, 'admin_id' => AuthAdmin::admin(false), 'tpl_title' => 'CRM Advertiser Overview', 'new_lead' => 'advertisers']);
}
这是来自我的控制器的代码,用于显示列表的视图。这就是我困惑的地方,如果单击href,我将如何传递该状态和id。
public function index($param)
{
$query = AdvertiserApplication::with('admin');
$status = Input::get('status');
if (!empty($status) || $status === '0')
$query->where('status', '=', $status);
$applications = $query->get();
return View::make('admin.advertisers.application_list', ['applications' => $applications, 'admin_id' => AuthAdmin::admin(false)]);
}
现在我不确定这是否是我在href中写的链接的正确方式。我应该做一个URL链接到路由或类似的东西吗?我还不确定。任何提示都将不胜感激!
有了这个你的URL:
<a href="/ap1/{{$new_lead}}/applications?status=2">{{ isset($status[2]) ? $status[2] : 0 }}</a>
如果你有
route::get('/ap1/{new_lead}', array('as' => 'page-name', 'uses' => 'yourController@functionName'));
在控制器中:
public function functionName($new_lead){
// use $new_lead here to get your data
}