|
17 | 17 | use App\User; |
18 | 18 | //classes |
19 | 19 | use Auth; |
| 20 | +use Cache; |
20 | 21 | use DB; |
21 | 22 | use Illuminate\Http\Request; |
22 | 23 |
|
@@ -58,27 +59,32 @@ public function __construct(Request $req) |
58 | 59 | */ |
59 | 60 | public function getFilter(Request $request) |
60 | 61 | { |
61 | | - $table = $this->table(); |
62 | | - if ($request->has('segment')) { |
63 | | - $segment = $this->request->input('segment'); |
64 | | - $table = $this->formatUserTickets($segment); |
65 | | - } else { |
66 | | - if ($request->has('api') && $request->get('api') == '1') { |
67 | | - $inputs = []; |
68 | | - foreach ($request->all() as $key => $value) { |
69 | | - if ($key != 'api' && $key != 'token' && $key != 'page' && $key |
70 | | - != 'sort-by' && $key != 'order' && $key != 'records_per_page') { |
71 | | - $inputs[$key] = explode(',', $value); // |
72 | | - } |
73 | | - } |
| 62 | + $cacheKey = 'agent_tickets_page_'.Auth::id().'_'.md5($request->getRequestUri()); |
74 | 63 |
|
75 | | - return $table = $this->checkRequestIsCorrect($table, $inputs); |
| 64 | + $table = Cache::remember($cacheKey, 300, function () use ($request) { |
| 65 | + $table = $this->table(); |
| 66 | + if ($request->has('segment')) { |
| 67 | + $segment = $this->request->input('segment'); |
| 68 | + $table = $this->formatUserTickets($segment); |
76 | 69 | } else { |
77 | | - $inputs = json_decode(htmlspecialchars_decode($request->get('options'))); |
78 | | - // dd($inputs); |
79 | | - $table = $this->checkRequestIsCorrect($table, (array) $inputs); |
| 70 | + if ($request->has('api') && $request->get('api') == '1') { |
| 71 | + $inputs = []; |
| 72 | + foreach ($request->all() as $key => $value) { |
| 73 | + if ($key != 'api' && $key != 'token' && $key != 'page' && $key |
| 74 | + != 'sort-by' && $key != 'order' && $key != 'records_per_page') { |
| 75 | + $inputs[$key] = explode(',', $value); // |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + $table = $this->checkRequestIsCorrect($table, $inputs); |
| 80 | + } else { |
| 81 | + $inputs = json_decode(htmlspecialchars_decode($request->get('options'))); |
| 82 | + $table = $this->checkRequestIsCorrect($table, (array) $inputs); |
| 83 | + } |
80 | 84 | } |
81 | | - } |
| 85 | + |
| 86 | + return $table; |
| 87 | + }); |
82 | 88 |
|
83 | 89 | return \Ttable::genreateTableJson($table); |
84 | 90 | } |
|
0 commit comments