1
|
|
|
<?php namespace jlourenco\base\Controllers;
|
2
|
|
|
|
3
|
|
|
use App\Http\Controllers\Controller;
|
4
|
|
|
use App\Http\Requests;
|
5
|
|
|
use jlourenco\base\Models\Logs;
|
6
|
|
|
use jlourenco\base\Models\Jobs;
|
7
|
|
|
use jlourenco\base\Models\Visits;
|
8
|
|
|
use Sentinel;
|
9
|
|
|
use Illuminate\Auth\Access\Response;
|
10
|
|
|
use Base;
|
11
|
|
|
|
12
|
|
|
class BaseController extends Controller
|
13
|
|
|
{
|
14
|
|
|
|
15
|
|
|
/**
|
16
|
|
|
* Logs frontend
|
17
|
|
|
*
|
18
|
|
|
* @return View
|
19
|
|
|
*/
|
20
|
|
|
public function getLogs()
|
21
|
|
|
{
|
22
|
|
|
// Show the page
|
23
|
|
|
return View('admin.logs.list');
|
24
|
|
|
}
|
25
|
|
|
|
26
|
|
|
/**
|
27
|
|
|
* Ajax call to get all the logs
|
28
|
|
|
*
|
29
|
|
|
* @return View
|
30
|
|
|
*/
|
31
|
|
|
public function ajaxGetLogs()
|
32
|
|
|
{
|
33
|
|
|
return \Response::json(array('data' => Base::getLogsRepository()->orderBy('created_at', 'desc')->take(300)->get(['ip', 'log', 'created_at', 'created_by', 'target'])));
|
34
|
|
|
}
|
35
|
|
|
|
36
|
|
|
/**
|
37
|
|
|
* Queues frontend
|
38
|
|
|
*
|
39
|
|
|
* @return View
|
40
|
|
|
*/
|
41
|
|
|
public function getQueues()
|
42
|
|
|
{
|
43
|
|
|
// Show the page
|
44
|
|
|
return View('admin.queues.list');
|
45
|
|
|
}
|
46
|
|
|
|
47
|
|
|
/**
|
48
|
|
|
* Ajax call to get all the queues
|
49
|
|
|
*
|
50
|
|
|
* @return View
|
51
|
|
|
*/
|
52
|
|
|
public function ajaxGetQueues()
|
53
|
|
|
{
|
54
|
|
|
$data = Base::getJobsRepository()->orderBy('created_at', 'desc')->take(300)->get(['queue', 'payload', 'attempts', 'reserved', 'reserved_at', 'created_at']);
|
55
|
|
|
|
56
|
|
|
foreach ($data as $d)
|
57
|
|
|
{
|
58
|
|
|
$obj = json_decode($d->payload);
|
59
|
|
|
$d->payload = $obj->job;
|
60
|
|
|
$d->data = json_encode($obj->data->data);
|
61
|
|
|
}
|
62
|
|
|
|
63
|
|
|
return \Response::json(array('data' => $data));
|
64
|
|
|
}
|
65
|
|
|
|
66
|
|
|
/**
|
67
|
|
|
* Visits frontend
|
68
|
|
|
*
|
69
|
|
|
* @return View
|
70
|
|
|
*/
|
71
|
|
|
public function getVisits()
|
72
|
|
|
{
|
73
|
|
|
// Show the page
|
74
|
|
|
return View('admin.visits.list');
|
75
|
|
|
}
|
76
|
|
|
|
77
|
|
|
/**
|
78
|
|
|
* Ajax call to get all the visits
|
79
|
|
|
*
|
80
|
|
|
* @return View
|
81
|
|
|
*/
|
82
|
|
|
public function ajaxGetVisits()
|
83
|
|
|
{
|
84
|
|
|
$data = Base::getVisitsRepository()->orderBy('created_at', 'desc')->take(300)->get(['url', 'browser', 'ip', 'created_at', 'country']);
|
85
|
|
|
|
86
|
|
|
return \Response::json(array('data' => $data));
|
87
|
|
|
}
|
88
|
|
|
|
89
|
|
|
}
|
90
|
|
|
|