Completed
Push — master ( 06b4a8...88e670 )
by Manel
05:44
created

DashboardController::tasks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Scool\EnrollmentMobile\Http\Controllers;
4
5
//use App\Activity;
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
6
//use App\Task;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Cache;
10
use Scool\EnrollmentMobile\Activity;
11
12
/**
13
 * Class DashboardController
14
 * @package App\Http\Controllers
15
 */
16
class DashboardController extends Controller
17
{
18
    //
19
    /**
20
     *
21
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
22
     */
23
    public function index()
24
    {
25
        $data = [];
26
27
        $data['labels1'] = "['January', 'February', 'March', 'April', 'May', 'June', 'July']";
28
        $data['values1'] = "[10, 42, 4, 23, 43, 54]";
29
30
        $data['labels2'] = "['January', 'February', 'March', 'April', 'May', 'June', 'July']";
31
        $data['values2'] = "[10, 42, 4, 23, 43, 54]";
32
        return view('enrollment_mobile::dashboard.dashboard',$data);
33
    }
34
35
    /**
36
     * @param $model
37
     * @return mixed
38
     */
39
    public function tasks($model)
40
    {
41
        return $model::all();
42
    }
43
44
    /**
45
     * @param $model
46
     * @return mixed
47
     */
48
    public function number($model)
49
    {
50
        $value = Cache::remember('tasksNumber',5, function () use ($model){
51
            //Codi a executar si cache MISS
52
//            return DB::table()->get();
53
// $this?
54
            $model='\\App\\'.ucfirst($model);
0 ignored issues
show
Bug introduced by
Consider using a different name than the imported variable $model, or did you forget to import by reference?

It seems like you are assigning to a variable which was imported through a use statement which was not imported by reference.

For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.

Change not visible in outer-scope

$x = 1;
$callable = function() use ($x) {
    $x = 2; // Not visible in outer scope. If you would like this, how
            // about using a different variable name than $x?
};

$callable();
var_dump($x); // integer(1)

Change visible in outer-scope

$x = 1;
$callable = function() use (&$x) {
    $x = 2;
};

$callable();
var_dump($x); // integer(2)
Loading history...
55
            return $model::all()->count();
56
        });
57
58
        return $value;
59
60
    }
61
62
    /**
63
     * @param $model
64
     */
65
    public function createRandom($model)
66
    {
67
        factory($model)->states('user')->create();
68
    }
69
70
    /**
71
     * @param $id
72
     * @return array
73
     */
74
    public function graph($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76
        $data = [];
77
        $data['labels'] = ['Pepe', 'Maria', 'Pedo', 'April', 'May', 'Abdul', 'Mare'];
78
        $data['values'] = [10, 42, 4, 23, 43, 54];
79
80
        return $data;
81
    }
82
83
    /**
84
     * @return mixed
85
     */
86
    public function fetchActivityFeed()
87
    {
88
        return Activity::all();
89
    }
90
}
91