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')) !!}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报