[194a359] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Controllers\Dashboard;
|
---|
| 4 |
|
---|
| 5 | use App\Helpers\Alert;
|
---|
[c6b84df] | 6 | use App\Models\Department;
|
---|
| 7 | use App\Models\Folder;
|
---|
| 8 | use App\Models\File;
|
---|
[194a359] | 9 | use App\Models\User;
|
---|
| 10 | use App\Http\Controllers\Controller;
|
---|
[4b7e2d3] | 11 | use Carbon\Carbon;
|
---|
| 12 | use Illuminate\Support\Facades\DB;
|
---|
[194a359] | 13 |
|
---|
| 14 | class IndexController extends Controller
|
---|
| 15 | {
|
---|
| 16 | public function index()
|
---|
| 17 | {
|
---|
| 18 | $counters = array(
|
---|
| 19 | "users" => User::count(),
|
---|
| 20 | );
|
---|
| 21 |
|
---|
[4b7e2d3] | 22 | $date = Carbon::today()->subDays(5);
|
---|
| 23 | $recentFiles = File::where('created_at', '>=', $date)->get();
|
---|
| 24 |
|
---|
| 25 | $year = ['2021','2022','2023','2024', '2025'];
|
---|
| 26 |
|
---|
| 27 | $file = [];
|
---|
| 28 | foreach ($year as $key => $value) {
|
---|
| 29 | $file[] = File::where(DB::raw("DATE_FORMAT(created_at, '%Y')"),$value)->count();
|
---|
| 30 | }
|
---|
| 31 |
|
---|
[194a359] | 32 | return view("dashboard.index")->with([
|
---|
| 33 | "counters" => $counters,
|
---|
[4b7e2d3] | 34 | "largestDepartments" => Department::orderBy('no_of_folders', 'desc')->limit(10)->get(),
|
---|
[c6b84df] | 35 | "folders" => Folder::all(),
|
---|
[4b7e2d3] | 36 | "files" => File::all(),
|
---|
| 37 | "recentFiles" => $recentFiles,
|
---|
| 38 | "year" => json_encode($year,JSON_NUMERIC_CHECK),
|
---|
| 39 | "file" => json_encode($file,JSON_NUMERIC_CHECK),
|
---|
| 40 | "departments" => Department::all(),
|
---|
| 41 | "excelExt" => array("xls", "xlsx", "xls", "csv"),
|
---|
| 42 | "textExt" => array("txt", "doc", "docx"),
|
---|
| 43 | "imageExt" => array("png", "jpg", "jpeg"),
|
---|
| 44 |
|
---|
| 45 | ]);
|
---|
[194a359] | 46 | }
|
---|
| 47 | }
|
---|