1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Scool\EnrollmentMobile\Http\Controllers; |
4
|
|
|
|
5
|
|
|
//use App\Activity; |
|
|
|
|
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\Models\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='\\Scool\EnrollmentMobile\Models\\'.ucfirst($model); |
55
|
|
|
return $model::all()->count(); |
56
|
|
|
// }); |
57
|
|
|
|
58
|
|
|
// return $value; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param $model |
63
|
|
|
*/ |
64
|
|
|
public function createRandom($model) |
65
|
|
|
{ |
66
|
|
|
// $model='\\Scool\EnrollmentMobile\Models\\'.ucfirst($model); |
|
|
|
|
67
|
|
|
$model='Scool\\EnrollmentMobile\\Models\\'.ucfirst($model); |
68
|
|
|
factory($model)->create(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param $id |
73
|
|
|
* @return array |
74
|
|
|
*/ |
75
|
|
|
public function graph($id) |
|
|
|
|
76
|
|
|
{ |
77
|
|
|
$data = []; |
78
|
|
|
$data['labels'] = ['Pepe', 'Maria', 'Pedo', 'April', 'May', 'Abdul', 'Mare']; |
79
|
|
|
$data['values'] = [10, 42, 4, 23, 43, 54]; |
80
|
|
|
|
81
|
|
|
return $data; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return mixed |
86
|
|
|
*/ |
87
|
|
|
public function fetchActivityFeed() |
88
|
|
|
{ |
89
|
|
|
return Activity::all(); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
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.