add metrics
This commit is contained in:
75
app/Http/Controllers/Admin/Shop/PriceListValueController.php
Normal file
75
app/Http/Controllers/Admin/Shop/PriceListValueController.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Shop;
|
||||
|
||||
use App\Datatables\Shop\PriceListValuesDataTable;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Shop\Packages;
|
||||
use App\Repositories\Shop\PriceListValueCategories;
|
||||
use App\Repositories\Shop\PriceListValues;
|
||||
use App\Repositories\Shop\Taxes;
|
||||
use App\Repositories\Shop\Unities;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PriceListValueController extends Controller
|
||||
{
|
||||
public function index(PriceListValuesDataTable $dataTable)
|
||||
{
|
||||
$data['categories'] = PriceListValueCategories::getOptions();
|
||||
|
||||
return $dataTable->render('Admin.Shop.PriceListValues.list', $data);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['unities'] = Unities::getOptions();
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceListValueCategories::getOptions();
|
||||
|
||||
return view('Admin.Shop.PriceListValues.create', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['generic'] = PriceListValues::getFull($id)->toArray();
|
||||
$data['packages'] = Packages::getSelectByFamily($data['generic']['category']['article_family_id']);
|
||||
$data['unities'] = ($data['packages']['id'] ?? false) ? Unities::getSelectByPackage($data['packages']['id']) : [];
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceListValueCategories::getOptions();
|
||||
|
||||
return view('Admin.Shop.PriceListValues.edit', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = PriceListValues::store($request->all());
|
||||
|
||||
return redirect()->route('Admin.Shop.PriceListValues.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = PriceListValues::get($id);
|
||||
|
||||
return view('Admin.Shop.PriceListValues.view', $data);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return PriceListValues::destroy($id);
|
||||
}
|
||||
|
||||
public function getPrice($id)
|
||||
{
|
||||
$data['generic'] = PriceListValues::getFull($id);
|
||||
|
||||
return view('Admin.Shop.PriceListValues.partials.table-prices', $data);
|
||||
}
|
||||
|
||||
public function addPrice($index)
|
||||
{
|
||||
$data['index'] = $index;
|
||||
|
||||
return view('Admin.Shop.PriceListValues.partials.row_price', $data);
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,11 @@ class Order extends Model
|
||||
return $query->where('delivery_id', $deliveryId);
|
||||
}
|
||||
|
||||
public function scopeWaiting($query)
|
||||
{
|
||||
return $query->byStatus(0);
|
||||
}
|
||||
|
||||
public function scopePreparation($query)
|
||||
{
|
||||
return $query->byStatus(1);
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Basket;
|
||||
use App\Traits\Model\Basic;
|
||||
use Darryldecode\Cart\CartCollection;
|
||||
|
||||
class BasketStores
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public function has($key)
|
||||
{
|
||||
return Basket::find($key);
|
||||
@@ -14,30 +17,29 @@ class BasketStores
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if($this->has($key))
|
||||
{
|
||||
if($this->has($key)) {
|
||||
return new CartCollection(Basket::find($key)->cart_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function put($key, $value)
|
||||
{
|
||||
if($row = Basket::find($key))
|
||||
{
|
||||
if($row = Basket::find($key)) {
|
||||
// update
|
||||
$row->cart_data = $value;
|
||||
$row->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Basket::create([
|
||||
'id' => $key,
|
||||
'cart_data' => $value
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Basket::query();
|
||||
}
|
||||
}
|
||||
|
||||
32
app/Repositories/Shop/CustomerMetrics.php
Normal file
32
app/Repositories/Shop/CustomerMetrics.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Customer;
|
||||
use App\Repositories\Core\DateStats;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class CustomerMetrics
|
||||
{
|
||||
use Basic, DateStats;
|
||||
|
||||
public static function countOfToday()
|
||||
{
|
||||
return Customer::ofToday()->count();
|
||||
}
|
||||
|
||||
public static function countOfLastWeek()
|
||||
{
|
||||
return Customer::ofLastWeek()->count();
|
||||
}
|
||||
|
||||
public static function countOfLastMonth()
|
||||
{
|
||||
return Customer::ofLastMonth()->count();
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Customer::query();
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,15 @@ class Dashboards
|
||||
'orders_count' => OrderMetrics::countByPeriod($start, $end),
|
||||
'orders_sum' => OrderMetrics::sumByPeriod($start, $end, 'total_shipped'),
|
||||
'orders_avg' => OrderMetrics::avgByPeriod($start, $end, 'total_shipped'),
|
||||
'offers_count' => Offers::count(),
|
||||
'clients_count' => Customers::count(),
|
||||
'countClients' => CustomerMetrics::countByPeriod($start, $end),
|
||||
'waitingOrders' => OrderMetrics::countWaiting(),
|
||||
'preparationLess24H' => OrderMetrics::countPreparationLess24h(),
|
||||
'preparationLess48H' => OrderMetrics::countPreparationLess48h(),
|
||||
'preparationMore48H' => OrderMetrics::countPreparationMore48h(),
|
||||
'offers_count' => Offers::count(),
|
||||
'stocksWarning' => OfferStocks::countAlerts(),
|
||||
'countCustomers' => Customers::count(),
|
||||
'lastOrders' => Orders::getLast(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ class OrderMetrics
|
||||
return self::sumMonthly('total_taxed');
|
||||
}
|
||||
|
||||
public static function countWaiting()
|
||||
{
|
||||
return Order::waiting()->count();
|
||||
}
|
||||
|
||||
public static function countPreparationLess24h()
|
||||
{
|
||||
$date = now()->subHours(24);
|
||||
|
||||
@@ -14,6 +14,11 @@ class Orders
|
||||
{
|
||||
use Basic, DateStats;
|
||||
|
||||
public static function getLast($nb = 10)
|
||||
{
|
||||
return Order::with('customer')->orderBy('id', 'DESC')->take($nb)->get();
|
||||
}
|
||||
|
||||
public static function getPdfByUUID($uuid)
|
||||
{
|
||||
return self::getPdf(self::getIdByUUID($uuid), 'commande-' . $uuid . '.pdf');
|
||||
|
||||
Reference in New Issue
Block a user