এই লেসনে আমরা আমাদের POS এর Dashboard এ কিছু Card যুক্ত করবো যেগুলি টোটাল হিসেবে দেখাবে।
DashboardController.php
namespace App\Http\Controllers;
use App\Payment;
use App\Product;
use App\PurchaseItem;
use App\Receipt;
use App\SaleItem;
use App\User;
use Illuminate\Http\Request;
class DashboardController extends Controller
{
public function __construct()
{
parent::__construct();
$this->data['main_manu'] = 'Dashboard';
}
public function index()
{
$this->data['totalUsers'] = User::count('id');
$this->data['totalProducts'] = Product::count('id');
$this->data['totalSales'] = SaleItem::sum('total');
$this->data['totalPurchases'] = PurchaseItem::sum('total');
$this->data['totalReceipts'] = Receipt::sum('amount');
$this->data['totalPayments'] = Payment::sum('amount');
$this->data['totalStock'] = PurchaseItem::sum('quantity') - SaleItem::sum('quantity');
return view('dashboard', $this->data);
}
}
dashboard.blade.php
@extends('layout.main')
@section('main_content')
<div class="row">
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1"> Total Stock </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalStock }} </div>
</div>
<div class="col-auto">
<i class="fas fa-calendar fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-success shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"> Total Products </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalProducts }} </div>
</div>
<div class="col-auto">
<i class="fas fa-calendar fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"> Total Sales </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalSales }} </div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"> Total Purchses </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalPurchases }} </div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1"> Total Users </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalUsers }} </div>
</div>
<div class="col-auto">
<i class="fas fa-users fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"> Total Receipts </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalReceipts }} </div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"> Total Payments </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalPayments }} </div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"> Cash In Hand </div>
<div class="h5 mb-0 font-weight-bold text-gray-800"> {{ $totalReceipts - $totalPayments }} </div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
</div>
@stop