1:I am creating referral system In laravel.SO I am using cookies.Problem Is that I am unable to retrieve referral user on blade template. 2:Here is cookie code. // Check that there is not already a cookie set and that we have 'ref' in
the url
if (! $request->hasCookie('referral') && $request->query('ref') ) {
// Add a cookie to the response that lasts 5 years (in minutes)
$response->cookie( 'referral', encrypt( $request->query('ref') ), 525600 );
}
else {
if( $request->query('ref') ) {
return redirect($request->fullUrl())->withCookie(cookie()->forever('referral', $request->query('ref')));
}
}
return $next($request);
2:Here is Crete function code
protected function create(array $data)
{
$cookie = Cookie::get('referral');
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'referred_by' => $referred_by
]);
}
Note : I want explain one thing is here. this line of code
$referred_by = Cookie::get('referral');
is Return this type of output s:2:"21";.
Important issue. My problem is That, how can I retrieve this value on blade temple page. This is database column value referred_by=s:2:"21"; So I need help to retrieve this value for human reading . Thanks.If any thing missing please let me know.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2M847Ik
via IFTTT
Aucun commentaire:
Enregistrer un commentaire