Im trying to figure out what is best and easy way without writing much code. So there is Admin panel and I want many stuff to show from database info, like how many users, how many posts and etc.
Here is controller:
public function userCount()
{
$count = DB::select('select count(*) as total from users');
return view('/admin', ['count' => $count[0]->total]);
}
Then here is Route:
Route::get('/admin', [AdminController::class, 'userCount']);
And then in admin.blade.php where is info just printing
The question is if its right way to make like this or there is better way? Example I can create maybe 1 controller "InfoController" and get all info from FB, create them as a functions and then print in admin.blade.php? Should I be using for every function a new route? Also if there is any fixes in code, maybe something should be deleted and no need, you can advice me. Thanks!
source https://stackoverflow.com/questions/67746475/not-sure-if-this-is-hard-or-easy-way-need-advice-with-getting-info-from-databas
Comments
Post a Comment