Test Failed
Push — dev5a ( 7155d2...8099d5 )
by Ron
07:36
created

GetUserStats::checkCustomerForFav()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Domains\User;
4
5
use Illuminate\Support\Facades\Log;
6
7
use Carbon\Carbon;
8
9
use App\FileLInks;
10
use App\TechTipFavs;
11
use App\CustomerFavs;
12
13
class GetUserStats
14
{
15
    protected $userID;
16
17 10
    public function __construct($userID)
18
    {
19 10
        $this->userID = $userID;
20 10
    }
21
22
    //  Get all Customer Favorites assigned to the user
23 4
    public function getUserCustomerFavs()
24
    {
25 4
        $favs = CustomerFavs::where('user_id', $this->userID)->get();
26 4
        Log::debug('Customer Favorites for User ID '.$this->userID.' gathered.  Data - ', $favs->toArray());
27
28 4
        return $favs->makeHidden('Customers');
29
    }
30
31
    //  Check if a customer is listed as a favorite for the user
32 4
    public function checkCustomerForFav($custID)
33
    {
34 4
        return CustomerFavs::where('user_id', $this->userID)->where('cust_id', $custID)->first();
35 4
    }
36
37 4
    //  Get all Tech Tip Favorites assigned to the user
38
    public function getUserTipFavs()
39
    {
40
        $favs = TechTipFavs::where('user_id', $this->userID)->get();
41 4
        Log::debug('Tech Tip Favorites for User ID '.$this->userID.' gathered.  Data - ', $favs->toArray());
42
43 4
        return $favs->makeHidden('TechTips');
44 4
    }
45
46 4
    //  Get a count of acctive file links the user has
47
    public function getUserActiveLinks()
48
    {
49
        $activeLinks = FileLinks::where('user_id', $this->userID)->where('expire', '>', Carbon::now())->count();
50 4
        Log::debug('Retrieved count of active File Links for User ID'.$this->userID.'. Data - ', ['Active Links' => $activeLinks]);
51
52 4
        return $activeLinks;
53 4
    }
54
55 4
    //  Get the total count of file links the user has
56
    public function getUserTotalLinks()
57
    {
58
        $totalLinks  = FileLinks::where('user_id', $this->userID)->count();
59
        Log::debug('Retrieved count of total File Links for User ID'.$this->userID.'. Data - ', ['Total Links' => $totalLinks]);
60
61
        return $totalLinks;
62
    }
63
}
64