@extends('layouts.app') @section('content') @php $now = \Carbon\CarbonImmutable::today()->locale('fr_FR'); $today = explode(' ', $now->toDateTimeString())[0]; $idStatePaid = App\Models\State::where('name', 'PAID')->first()->id; $idStatePending = App\Models\State::where('name', 'PENDING')->first()->id; //Today Sell $startOfDay = $now->startOfDay()->toDateTimeString(); $endOfDay = $now->endOfDay()->toDateTimeString(); $sells = App\Models\Sell::where('state_id', $idStatePaid)->whereBetween('date', [$startOfDay, $endOfDay])->get(); $todaySell = $sells->sum('total'); //Yesterday Sell $startOfDay = $now->subDay()->startOfDay()->toDateTimeString(); $endOfDay = $now->subDay()->endOfDay()->toDateTimeString(); $sells = App\Models\Sell::where('state_id', $idStatePaid)->whereBetween('date', [$startOfDay, $endOfDay])->get(); $yesterdaySell = $sells->sum('total'); //Week Sell $startOfWeek = $now->startOfWeek()->toDateTimeString(); $endOfWeek = $now->endOfWeek()->toDateTimeString(); $sells = App\Models\Sell::where('state_id', $idStatePaid)->whereBetween('date', [$startOfWeek, $endOfWeek])->get(); $weekSell = $sells->sum('total'); //Month Sell $startOfMonth = $now->startOfMonth()->toDateTimeString(); $endOfMonth = $now->endOfMonth()->toDateTimeString(); $sells = App\Models\Sell::where('state_id', $idStatePaid)->whereBetween('date', [$startOfMonth, $endOfMonth])->get(); $monthSell = $sells->sum('total'); $sellsInPending = App\Models\Sell::where('state_id', $idStatePending)->get(); $nbreSellsInPending = $sellsInPending->count(); @endphp
Aujourd'hui
Cette Semaine
Ce Mois