Probably a basic question but I can't seem to get it.
I am wanting to grab the variable in my url to my controller.
// index view
@foreach ($paymentInfos as $p)
<tr>
<td><a href="{{ URL::action('AdminController@getPackingSlip', array('order_id' => $p->order_id)) }}"> {{ $p->order_id }}</a></td>
<td>{{ $p->lastname }} {{ $p->firstname }}</td>
<td>{{ $p->buyer_email }}</td>
</tr>
@endforeach
// route
Route::get('printpackingslip', 'AdminController@getPackingSlip');
// Controller
class AdminController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getPackingSlip()
{
$rules = array('order_id' => 'order_id');
return View::make('admin.packingslip')->with($rules);
}
}
When you click on the link it goes to www.domain.com/printpackingslip?order_id=3
I do not know how to grab the order_id=3 in my controller.
Also would I be better off using the :(num) to generate a URI of /printpackingslip/3 or does it not matter?
For example:
// in my first view have:
<td><a href="{{ URL::to('printpackingslip', array('order_id' => $p->order_id)) }}"> {{ $p->order_id }}</a></td>
// then my route:
Route::get('printpackingslip/(:num)', 'AdminController@getPackingSlip');
Thanks!