<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Image;
use App\Models\NewsPodcasts;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class DashboardController extends Controller
{
protected $database;
public function __construct()
{
$this->database = app('firebase.database');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$news = NewsPodcasts::latest()->take(5)->get();
$news_count = NewsPodcasts::all()->count();
$app_images = Image::all()->count();
$programmes = count($this->database->getReference('schedule')->shallow()->getValue()??[]);
$fbLinks = count($this->database->getReference('facebook_link')->shallow()->getValue()??[]);
return view('admin.dashboard', compact('news_count', 'app_images', 'programmes', 'fbLinks', 'news'));
}
}