Files
sam-manage/app/Models/Stats/StatInventoryDaily.php

42 lines
979 B
PHP
Raw Normal View History

<?php
namespace App\Models\Stats;
use Illuminate\Database\Eloquent\Model;
class StatInventoryDaily extends Model
{
protected $connection = 'sam_stat';
protected $table = 'stat_inventory_daily';
protected $casts = [
'stat_date' => 'date',
'total_sku_count' => 'integer',
'below_safety_count' => 'integer',
'zero_stock_count' => 'integer',
'excess_stock_count' => 'integer',
'total_stock_value' => 'decimal:2',
'turnover_rate' => 'decimal:2',
];
public function scopeForTenant($query, ?int $tenantId)
{
if ($tenantId) {
return $query->where('tenant_id', $tenantId);
}
return $query;
}
public function scopeForDateRange($query, string $from, string $to)
{
return $query->whereBetween('stat_date', [$from, $to]);
}
public function scopeForDate($query, string $date)
{
return $query->where('stat_date', $date);
}
}