@@ 96-119 (lines=24) @@ | ||
93 | } |
|
94 | ||
95 | // Toggle whether or not the customer is listed as a user favorite |
|
96 | public function toggleFav($action, $id) |
|
97 | { |
|
98 | switch($action) |
|
99 | { |
|
100 | case 'add': |
|
101 | CustomerFavs::create([ |
|
102 | 'user_id' => Auth::user()->user_id, |
|
103 | 'cust_id' => $id |
|
104 | ]); |
|
105 | break; |
|
106 | case 'remove': |
|
107 | $custFav = CustomerFavs::where('user_id', Auth::user()->user_id)->where('cust_id', $id)->first(); |
|
108 | $custFav->delete(); |
|
109 | break; |
|
110 | } |
|
111 | ||
112 | Log::debug('Route '.Route::currentRouteName().' visited by User ID-'.Auth::user()->user_id); |
|
113 | Log::info('Customer Bookmark Updated.', [ |
|
114 | 'user_id' => Auth::user()->user_id, |
|
115 | 'cust_id' => $id, |
|
116 | 'action' => $action |
|
117 | ]); |
|
118 | return response()->json(['success' => true]); |
|
119 | } |
|
120 | } |
|
121 |
@@ 299-322 (lines=24) @@ | ||
296 | } |
|
297 | ||
298 | // Add or remove this tip as a favorite of the user |
|
299 | public function toggleFav($action, $id) |
|
300 | { |
|
301 | Log::debug('Route '.Route::currentRouteName().' visited by '.Auth::user()->full_name); |
|
302 | ||
303 | switch($action) { |
|
304 | case 'add': |
|
305 | TechTipFavs::create([ |
|
306 | 'user_id' => Auth::user()->user_id, |
|
307 | 'tip_id' => $id |
|
308 | ]); |
|
309 | break; |
|
310 | case 'remove': |
|
311 | $tipFav = TechTipFavs::where('user_id', Auth::user()->user_id)->where('tip_id', $id)->first(); |
|
312 | $tipFav->delete(); |
|
313 | break; |
|
314 | } |
|
315 | ||
316 | Log::debug('Tech Tip Bookmark Updated.', [ |
|
317 | 'user_id' => Auth::user()->user_id, |
|
318 | 'tip_id' => $id, |
|
319 | 'action' => $action |
|
320 | ]); |
|
321 | return response()->json(['success' => true]); |
|
322 | } |
|
323 | ||
324 | // Edit an existing tech tip |
|
325 | public function edit($id) |