1 | <?php |
||
7 | class ViewPostThrottleMiddleware |
||
8 | { |
||
9 | /** |
||
10 | * Views will expire after 12 hours. |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | protected $throttleTime = 43200; |
||
15 | |||
16 | /** |
||
17 | * @var Store |
||
18 | */ |
||
19 | protected $session; |
||
20 | |||
21 | /** |
||
22 | * ViewThrottleMiddleware constructor. |
||
23 | * @param Store $session |
||
24 | */ |
||
25 | public function __construct(Store $session) |
||
29 | |||
30 | /** |
||
31 | * Handle an incoming request. |
||
32 | * |
||
33 | * @param \Illuminate\Http\Request $request |
||
34 | * @param \Closure $next |
||
35 | * @param string|null $guard |
||
36 | * @return mixed |
||
37 | */ |
||
38 | public function handle($request, \Closure $next, $guard = null) |
||
51 | |||
52 | /** |
||
53 | * Get all the viewed posts from the session. If no |
||
54 | * entry in the session exists, default to null. |
||
55 | * |
||
56 | * @return mixed |
||
57 | */ |
||
58 | private function getViewedPosts() |
||
62 | |||
63 | /** |
||
64 | * Clean expired views. |
||
65 | * |
||
66 | * @param $posts |
||
67 | * @return array |
||
68 | */ |
||
69 | private function cleanExpiredViews($posts) |
||
84 | |||
85 | /** |
||
86 | * Push the post id onto the viewed_posts session array. |
||
87 | * |
||
88 | * @param $posts |
||
89 | */ |
||
90 | private function storePosts($posts) |
||
94 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.