改进 推介
This commit is contained in:
parent
8ccb270591
commit
59fb4f86bb
@ -65,10 +65,13 @@ public function store(Request $request): RedirectResponse
|
|||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*/
|
*/
|
||||||
public function show(Affiliates $affiliate): RedirectResponse
|
public function show($affiliate): RedirectResponse
|
||||||
{
|
{
|
||||||
if (auth('web')->guest()) {
|
$redirect = redirect()->route('index');
|
||||||
// save the affiliate id in the session
|
|
||||||
|
$affiliate = Affiliates::where('uuid', $affiliate)->first();
|
||||||
|
|
||||||
|
if (auth('web')->guest() && $affiliate) {
|
||||||
session()->put('affiliate_id', $affiliate->id);
|
session()->put('affiliate_id', $affiliate->id);
|
||||||
|
|
||||||
$cache_key = 'affiliate_ip:'.$affiliate->id.':'.request()->ip();
|
$cache_key = 'affiliate_ip:'.$affiliate->id.':'.request()->ip();
|
||||||
@ -77,9 +80,11 @@ public function show(Affiliates $affiliate): RedirectResponse
|
|||||||
$affiliate->increment('visits');
|
$affiliate->increment('visits');
|
||||||
Cache::put($cache_key, true, now()->addHour());
|
Cache::put($cache_key, true, now()->addHour());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$redirect->with('error', '此推介链接已失效。');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('index');
|
return $redirect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user