Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
app
/
Models
:
ReportSales.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class ReportSales extends Model { use HasFactory; protected $table = 'report_sales'; 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; } }