add nova
This commit is contained in:
42
nova/src/Metrics/SqlSrvTrendDateExpression.php
Normal file
42
nova/src/Metrics/SqlSrvTrendDateExpression.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Metrics;
|
||||
|
||||
class SqlSrvTrendDateExpression extends TrendDateExpression
|
||||
{
|
||||
/**
|
||||
* Get the value of the expression.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
$column = $this->wrap($this->column);
|
||||
$offset = $this->offset();
|
||||
|
||||
if ($offset >= 0) {
|
||||
$interval = $offset;
|
||||
} else {
|
||||
$interval = '-'.($offset * -1);
|
||||
}
|
||||
|
||||
$date = "DATEADD(hour, {$interval}, {$column})";
|
||||
|
||||
switch ($this->unit) {
|
||||
case 'month':
|
||||
return "FORMAT({$date}, 'yyyy-MM')";
|
||||
case 'week':
|
||||
return "concat(
|
||||
YEAR({$date}),
|
||||
'-',
|
||||
datepart(ISO_WEEK, {$date})
|
||||
)";
|
||||
case 'day':
|
||||
return "FORMAT({$date}, 'yyyy-MM-dd')";
|
||||
case 'hour':
|
||||
return "FORMAT({$date}, 'yyyy-MM-dd HH:00')";
|
||||
case 'minute':
|
||||
return "FORMAT({$date}, 'yyyy-MM-dd HH:mm:00')";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user