[英]how to access values from result returned by eloquent model in laravel 5.1
I want to access the data which is returned by eloquent model in my code. 我想访问我的代码中雄辩模型返回的数据。 but i am making mistakes.
但是我在犯错误。 I need help to sort out this , My code
我需要帮助来解决这个问题,我的代码
public function success(Request $request)
{
$paymentstatus=$request->input('status');
$transactionid=$request->input('txnid');
Ticket::where('transactionid',$transactionid)->update(['paymentstatus'=>$paymentstatus]);
$ticketdata=Ticket::where('transactionid',$transactionid)->get();
$message="Ticket#:{{$ticketdata->ticketid}}";
SmsController::sendsms($request->input('phone'),$message); //use of sms controller class & function to send sms
return $request->all();
}
I am getting error for this line, I doubt that it isn't correctly accessed . 我在此行出现错误,我怀疑它没有正确访问。
$message="Ticket#:{{$ticketdata->ticketid}}";
Please help me rectify this line. 请帮助我纠正这一行。
you are using get request,if you using get method, it will take more that one row.So if you use get first you need to foreach,otherwise you have to user first method.Follow my code 您正在使用get请求,如果您使用get方法,则将花费多于一行。因此,如果您使用get first,则需要进行each操作,否则必须使用first方法。按照我的代码
public function success(Request $request)
{
$paymentstatus=$request->input('status');
$transactionid=$request->input('txnid');
Ticket::where('transactionid',$transactionid)->update(['paymentstatus'=>$paymentstatus]);
$ticketdata=Ticket::where('transactionid',$transactionid)->first();
$message="Ticket#:{{$ticketdata->ticketid}}";
SmsController::sendsms($request->input('phone'),$message); //use of sms controller class & function to send sms
return $request->all();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.