I have the following url http://project.su/?invitee=95

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

我try 过的(控制器):

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

The following code is not working .

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

谢谢

推荐答案

To determine if an input value is present:

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

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

Laravel相关问答推荐

laravel错误更新使用外键的数据库

如何在Laravel中从多行中获取合并数组?

如何定制有关密码被泄露的Laravel Breeze S消息?

LaravelEloquent 的模型如何将值从控制器内部的函数传递到Render()

laravel如何在Blade 模板中将元素添加到数组

Laravel Eloquent查询与集合优化

验证规则 required_if 与其他条件(Laravel 5.4)

如何在 Laravel 5.5 中扩展 vendor 包服务提供者

Laravel 的 APP_ENV 变量(在 .env 文件中找到)是否有建议的值列表?

Laravel 5 - 没有重叠的任务计划不起作用

Laravel Eloquent 模型中的字段

Laravel assets资源与混合

Laravel - 语法错误,文件意外结束

升级到 laravel 5.3 后错误 datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00'

Laravel:在另一个控制器中加载方法而不更改 url

laravel 队列 - 同步驱动程序如何工作?它是在单独的进程/线程还是主执行线程中执行?

Laravel 隐藏属性.例如密码 - 安全

Laravel 在域和子域中共享 cookie 检测问题

Laravel X-CSRF-Token 与 POSTMAN 不匹配

如果在 Laravel 5.1 中找不到路由,则显示 404 页面