HomeController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Model\helpdesk\Ticket\Tickets;
6
7
class HomeController extends Controller
8
{
9
    /*
10
      |--------------------------------------------------------------------------
11
      | Home Controller
12
      |--------------------------------------------------------------------------
13
      |
14
      | This controller renders your application's "dashboard" for users that
15
      | are authenticated. Of course, you are free to change or remove the
16
      | controller as you wish. It is just here to get your app started!
17
      |
18
     */
19
20
    /**
21
     * Create a new controller instance.
22
     *
23
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
24
     */
25
    public function __construct()
26
    {
27
        // $this->middleware('auth');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
    }
29
30
    /**
31
     * Show the application dashboard to the user.
32
     *
33
     * @return Response
34
     */
35
    public function index()
36
    {
37
        // ksjdckjdsnc
38
        return view('themes/default1/admin/dashboard');
39
    }
40
41
    public function getdata()
42
    {
43
        return \View::make('emails/notifications/agent');
44
    }
45
46
    public function getreport()
47
    {
48
        return \View::make('test');
49
    }
50
51
    public function pushdata()
52
    {
53
        $date2 = strtotime(date('Y-m-d'));
54
        $date3 = date('Y-m-d');
55
        $format = 'Y-m-d';
56
        $date1 = strtotime(date($format, strtotime('-1 month'.$date3)));
57
58
        $return = '';
59
        $last = '';
0 ignored issues
show
Unused Code introduced by
$last is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
60
        for ($i = $date1; $i <= $date2; $i = $i + 86400) {
61
            $thisDate = date('Y-m-d', $i);
62
63
            $created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
64
            $closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
65
            $reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
66
67
            $value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
68
            $array = array_map('htmlentities', $value);
69
            $json = html_entity_decode(json_encode($array));
70
            $return .= $json.',';
71
        }
72
        $last = rtrim($return, ',');
73
74
        return '['.$last.']';
75
    }
76
}
77