Test Failed
Push — dev5 ( 1b6b88...9ca56e )
by Ron
09:04
created

GetUserStats::getUserCustomerFavs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace App\Domains\Users;
4
5
// use App\CustomerFileTypes;
6
// use App\Http\Resources\CustomerFileTypesCollection;
7
use Illuminate\Support\Facades\Auth;
8
9
use Carbon\Carbon;
10
use App\User;
11
use App\CustomerFavs;
12
use App\TechTipFavs;
13
use App\FileLinks;
14
15
class GetUserStats
16
{
17
    protected $userID;
18
19
    public function __construct($userID = null)
20
    {
21
        $userID ? $this->userID = $userID : $this->userID = Auth::user()->user_id;
22
    }
23
24
    public function getUserCustomerFavs()
25
    {
26
        $custFavs    = CustomerFavs::where('user_id', $this->userID)
27
            ->with(array('Customers' => function($query){
28
                $query->select('cust_id', 'name');
29
            }))
30
            ->get();
31
32
        return $custFavs;
33
    }
34
35
    public function getUserTechTipFavs()
36
    {
37
        $tipFavs     = TechTipFavs::where('user_id', $this->userID)
38
            ->with(array('TechTips' => function($query){
39
                $query->select('tip_id', 'subject');
40
            }))
41
            ->get();
42
43
        return $tipFavs;
44
    }
45
46
    public function getUserActiveFileLinks()
47
    {
48
        $activeLinks = FileLinks::where('user_id', Auth::user()->user_id)->where('expire', '>', Carbon::now())->count();
49
        return $activeLinks;
50
    }
51
52
    public function getUserTotalLinks()
53
    {
54
        $totalLinks  = FileLinks::where('user_id', Auth::user()->user_id)->count();
55
        return $totalLinks;
56
    }
57
}
58