Passed
Branch dev5a (8099d5)
by Ron
07:27
created

SetUserFavorites   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 19
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toggleCustomerFavorite() 0 17 2
1
<?php
2
3
namespace App\Domains\User;
4
5
use App\CustomerFavs;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
9
10
class SetUserFavorites
11
{
12 6
    public function toggleCustomerFavorite($custID, $userID)
13
    {
14 6
        $favData = CustomerFavs::where('cust_id', $custID)->where('user_id', $userID)->first();
15
16 6
        if($favData)
17
        {
18 4
            Log::info('Customer Favorite Removed.  Data - ', ['user_id' => $userID, 'cust_id' => $custID]);
19 4
            $favData->delete();
20 4
            return false;
21
        }
22
23 4
        Log::info('Customer Favorite Addes.  Data - ', ['user_id' => $userID, 'cust_id' => $custID]);
24 4
        CustomerFavs::create([
25 4
            'user_id' => $userID,
26 4
            'cust_id' => $custID,
27
        ]);
28 4
        return true;
29
    }
30
}
31