laravel 5.2:获取查询字符串 [英] laravel 5.2 : Get query string

查看:50
本文介绍了laravel 5.2:获取查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下网址 http://project.su/?invitee=95

首先,我要检查url中的 invitee ,如果url中有 invitee ,则获取值.

first i want to check the invitee in url, if the url have invitee then get the value.

我尝试过的(控制器):

What i have tried (controller) :

if(!empty($request->get('invitee'))){
   $user->invitee = $request->get('invitee');
}

以下代码不起作用.

我想将 invitee result(id)结果(id)存储在数据库中.

I want storing the invitee result(id) in database.

谢谢.

推荐答案

确定输入值是否存在:

if ($request->has('invitee')) {
       $user->invitee = $request->input('invitee');
}

如果该值存在且不是空字符串,则 has 方法将返回true:

The has method returns true if the value is present and is not an empty string:

这篇关于laravel 5.2:获取查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆