I've used auth scaffold to create login and auth system for my site. I want to count the post and show it in the dashboard. But in LoginController.php
and RegisterController.php
there is just one line code protected $redirectTo = '/home';
to return view. How do i count post and show it in the dashboard.
Thanks to everyone who tried to help me out.
I found that when we use laravel auth scaffolding laravel uses use AuthenticatesUsers;
in LoginController.php
and use RegistersUsers;
in RegisterController.php
which is known as trait. And both trait use another trait RedeirectUsers.php
to redirect or show view after we login or register a new user. It would not be a nice idea messing up those files.But instead I used balde injection method in dashboard.blade.php
@inject('posts','App\Post') //place it in top of dashboard.blade.php
{{$posts->count()}}
No need to make extra view,models & controller to pass data to dashboard