我想将一个值发送给我从控制器收到的路由。我怎么能这样做。
我的控制器:
public function payment_history($id)
{
$payment_details=AmountDrvPaidHistoryModel::where('driver_id',$id)->get();
return view('admin.driver_payment_history')->with('payment_details',$payment_details)->with(array('id'=>$id));
}
这是我的刀片:
<form action="{{URL::to('driver_payment_history/'.$id)}}" method="post">
如何获取发送到另一条路线的动作标签中的id值。
答案 0 :(得分:0)
您的代码将是:
public function payment_history($id)
{
$payment_details = AmountDrvPaidHistoryModel::where('driver_id',$id)->get();
return view('admin.driver_payment_history', compact('payment_details', 'id'));
}
使用compact
,您可以获取变量数据,因此$id
会传递给视图。
您可以使用以下代码获取id
:
<form action="{{ url('driver_payment_history/'.$id) }}" method="post">
修改强>
<form action="{{ url('driver_payment_history/'.$payment_details[0]->driver_id) }}" method="post">
希望这有效!
答案 1 :(得分:0)
从这个
中删除数组->with('id'=>$id);
答案 2 :(得分:0)
您必须引用函数内的public function payment_history($id) //<-this is the parameter passed into the function
{
$payment_details=AmountDrvPaidHistoryModel::where('driver_id',$id)->get();
$new_var_id = $id; //<- Assign the $id to a new variable (eg. $new_var_id)
return view('admin.driver_payment_history',compact('payment_details','new_var_id');
}
,启动它以通过特定函数传递。
<form action="{{ url('driver_payment_history/'.$new_var_id) }}" method="post">
然后您将如此访问变量
$id
但请注意,您已使用$id
变量执行get请求,并将所有结果发送到该页面。这意味着您只需访问对象属性即可访问视图中的特定ID,而无需重新启动<form action="{{ url('driver_payment_history/'.$payment_details->driver_id) }}" method="post">
变量。
$new_var_id
如果您使用此功能,则可以从控制器中删除compact()
(或您命名的任何内容),并将其从Global fso As New FileSystemObject
Public Sub MaakKoppelingenRelatief()
Dim i As Integer
Dim sld As Slide, shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.Type = 3 Then
Dim path As String, fname As String
path = shp.LinkFormat.SourceFullName
fname = GetFilenameFromPath(path)
shp.LinkFormat.SourceFullName = fname
i = i + 1
End If
Next
Next
If i > 0 Then
MsgBox "Changed: " & CStr(i) & " Links", vbOK
Else
MsgBox "Couldn't find a linked file.", vbOK
End If
End Sub
Function GetFilenameFromPath(ByVal strPath As String) As String
Dim text1 As String
text1 = "N:\"
If Right$(strPath, 13) <> "\\tsclient\N\" And Len(strPath) > 0 Then
GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
End If
If Left$(strPath, 3) <> text1 And Len(strPath) > 0 Then
GetFilenameFromPath = text1 + strPath
End If
End Function