Passed
Push — dev5a ( 915c64...c2cba2 )
by Ron
07:58
created

GetUserStats::getUserActiveLinks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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