|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\Components; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\View\Component; |
|
6
|
|
|
|
|
7
|
|
|
class DateRange extends Component |
|
8
|
|
|
{ |
|
9
|
|
|
public $topclass, $inputclass, $title, $icon, $id; |
|
10
|
|
|
public $init; |
|
11
|
|
|
public $callback; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct( |
|
14
|
|
|
$id, $topclass = null, $title = 'Filter Range', $icon = 'far fa-calendar-alt', |
|
15
|
|
|
$init = 2, $callback = null, $inputclass = null |
|
16
|
|
|
) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->id = $id; |
|
19
|
|
|
$this->topclass = $topclass; |
|
20
|
|
|
$this->inputclass = $inputclass; |
|
21
|
|
|
$this->title = $title; |
|
22
|
|
|
$this->icon = $icon; |
|
23
|
|
|
$this->init = $init; |
|
24
|
|
|
$this->callback = $callback; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function initiator() |
|
28
|
|
|
{ |
|
29
|
|
|
switch($this->init) |
|
30
|
|
|
{ |
|
31
|
|
|
case 0 : $s = "startDate: moment(), endDate: moment()"; break; |
|
32
|
|
|
case 1 : $s = "startDate: moment().subtract(1, 'days'), endDate: moment().subtract(1, 'days')"; break; |
|
33
|
|
|
case 2 : $s = "startDate: moment().subtract(6, 'days'), endDate: moment()"; break; |
|
34
|
|
|
case 3 : $s = "startDate: moment().subtract(29, 'days'), endDate: moment()"; break; |
|
35
|
|
|
case 4 : $s = "startDate: moment().startOf('month'), endDate: moment().endOf('month')"; break; |
|
36
|
|
|
case 5 : $s = "startDate: moment().subtract(1, 'month').startOf('month'), endDate: moment().subtract(1, 'month').endOf('month')"; break; |
|
37
|
|
|
} |
|
38
|
|
|
return $s; |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function render() |
|
42
|
|
|
{ |
|
43
|
|
|
return view('adminlte::date-range'); |
|
44
|
|
|
} |
|
45
|
|
|
} |