I want to create a ref link like this in laravel 5.4Registration form emails example.com For every registered user and when the link is click it should redirect to the registration form where the ref value is automatically get into the REF form field as given in the image. Here are the related images RegistrationController
3条回答 默认 最新
- doucan1979 2017-05-21 06:09关注
Edit : Updated the link generation based on comments
Generate the referral link using the logged in user's email. Assuming you have the logged in user as
$user
, if not replace it withauth()->user()->email
. Note that this will need logged in user's email. So it goes without saying that you need to be logged in before to generate the ref link.If you pass the currently logged in user to your view from controller then do this, where
$user = auth()->user();
<a href="{{ route('register', ['ref' => $user->email]) }}" target="_blank">Referral register link</a>
If you want to directly access the logged in user's email
<a href="{{ route('register', ['ref' => auth()->user()->email]) }}" target="_blank">Referral register link</a>
This is how it would look like in the view.
<a href="http://example.com/register?ref=example@example.com" target="_blank">Referral register link</a>
Add the following code in your registration form depending on how you create the form.
<input type="text" name="referrer" value="{{ request('ref') }}"> Or {!! Form::text('referrer', request('ref')) !!}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 乌班图ip地址配置及远程SSH
- ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
- ¥15 PSPICE制作一个加法器
- ¥15 javaweb项目无法正常跳转
- ¥15 VMBox虚拟机无法访问
- ¥15 skd显示找不到头文件
- ¥15 机器视觉中图片中长度与真实长度的关系
- ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
- ¥15 java 的protected权限 ,问题在注释里
- ¥15 这个是哪里有问题啊?