From bdf9fc83d8656c857d6fe998d48c9cfffb016b6e Mon Sep 17 00:00:00 2001 From: sayliraut Date: Fri, 5 Jul 2024 19:46:27 +0530 Subject: [PATCH] changes --- .../Controllers/Admin/DashboardController.php | 18 +- app/Models/Subscriptions.php | 11 +- resources/views/Admin/dashboard.blade.php | 892 +++++------------- 3 files changed, 266 insertions(+), 655 deletions(-) diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index e311f29..0480db5 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -7,7 +7,7 @@ use Illuminate\Http\Request; use App\Models\IamPrincipal; use Illuminate\Support\Facades\DB; use App\Models\ManageRestaurant; - +use App\Models\Subscriptions; class DashboardController extends Controller { @@ -33,8 +33,7 @@ class DashboardController extends Controller ->pluck('count', 'month') ->toArray(); - $dataMonthlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - ->where('principal_type_xid', 4) + $dataMonthlyWithType4 = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) ->whereYear('created_at', date('Y')) ->groupBy(DB::raw("MONTH(created_at)")) ->orderBy(DB::raw("MONTH(created_at)")) @@ -54,8 +53,7 @@ class DashboardController extends Controller ->pluck('count', 'quarter') ->toArray(); - $dataQuarterlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter")) - ->where('principal_type_xid', 4) + $dataQuarterlyWithType4 = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter")) ->groupBy(DB::raw("QUARTER(created_at)")) ->orderBy(DB::raw("QUARTER(created_at)")) ->pluck('count', 'quarter') @@ -73,14 +71,15 @@ class DashboardController extends Controller ->pluck('count', 'year') ->toArray(); - $dataYearlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - ->where('principal_type_xid', 4) + $dataYearlyWithType4 = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) ->groupBy(DB::raw("YEAR(created_at)")) ->pluck('count', 'year') ->toArray(); $customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count(); - $restaurantCount = ManageRestaurant::where('is_active', 1)->count(); + $restaurantCount = Subscriptions::where('is_active', 1)->count(); + $recent_transaction = Subscriptions::with('subscription')->get()->toArray(); + return view('Admin.dashboard', compact( 'customerCount', @@ -90,7 +89,8 @@ class DashboardController extends Controller 'dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', - 'dataYearlyWithType4' + 'dataYearlyWithType4', + 'recent_transaction' )); } } diff --git a/app/Models/Subscriptions.php b/app/Models/Subscriptions.php index e5c15fb..349fa1e 100644 --- a/app/Models/Subscriptions.php +++ b/app/Models/Subscriptions.php @@ -11,9 +11,14 @@ class Subscriptions extends Model protected $table = 'subscriptions'; protected $guarded = []; - - - + + public function subscription() + { + return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id'); + } + + + } diff --git a/resources/views/Admin/dashboard.blade.php b/resources/views/Admin/dashboard.blade.php index 44f56ce..b146820 100644 --- a/resources/views/Admin/dashboard.blade.php +++ b/resources/views/Admin/dashboard.blade.php @@ -100,668 +100,274 @@ --}} - + --}} - - - -@endsection + @endsection -@section('section_script') - - var allIds = []; + - - $(document).on("click", "#download_all", function(e) { - $('#all_id').prop('disabled', false); - $('#ids').prop('disabled', true); - }) - }); - - $(document).on("click", ".more", function(e) { - e.preventDefault(); - e.stopPropagation(); - }); - - - - -@endsection + @endsection