Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
30 | 6 | public function toggleTechTipFavorite($tipID, $userID) |
|
31 | { |
||
32 | 6 | $favData = TechTipFavs::where('tip_id', $tipID)->where('user_id', $userID)->first(); |
|
33 | |||
34 | 6 | if($favData) |
|
35 | { |
||
36 | 4 | Log::info('Tech Tip Favorite Removed. Data - ', ['user_id' => $userID, 'tip_id' => $tipID]); |
|
37 | 4 | $favData->delete(); |
|
38 | 4 | return false; |
|
39 | } |
||
40 | |||
41 | 4 | Log::info('Tech Tip Favorite Added. Data - ', ['user_id' => $userID, 'tip_id' => $tipID]); |
|
42 | 4 | TechTipFavs::create([ |
|
43 | 4 | 'user_id' => $userID, |
|
44 | 4 | 'tip_id' => $tipID, |
|
45 | ]); |
||
46 | 4 | return true; |
|
47 | } |
||
49 |