File "ReportJobsCompleted.php"
Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Models/ReportJobsCompleted.php
File size: 1.41 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ReportJobsCompleted extends Model
{
use HasFactory;
protected $table = 'report_jobs_completed';
public const REPORTS_MODE = [
'previous_month' => 'previousMonth',
'current_month' => 'currentMonth',
'previous_year' => 'previousYear',
'current_year' => 'currentYear',
'all' => 'untilToday',
];
public function scopePreviousMonth($query)
{
$start_date = now()->startOfMonth()->subMonth();
$end_date = now()->endOfMonth()->subMonth();
$query->whereBetween('date', [$start_date, $end_date]);
}
public function scopeCurrentMonth($query)
{
$start_date = now()->startOfMonth();
$end_date = now()->endOfMonth();
$query->whereBetween('date', [$start_date, $end_date]);
}
public function scopePreviousYear($query)
{
$start_date = now()->startOfYear()->subYear();
$end_date = now()->endOfYear()->subYear();
$query->whereBetween('date', [$start_date, $end_date]);
}
public function scopeCurrentYear($query)
{
$start_date = now()->startOfYear();
$end_date = now()->endOfYear();
$query->whereBetween('date', [$start_date, $end_date]);
}
public function scopeUntilToday($query)
{
return $query;
}
}