Rainieren
1 year ago

Laravel - Show latest 5 Registered users

Posted 1 year ago by Rainieren

I'm trying to make a dashboard and I want to display the last 5 users that are registered on the site, So the most recent 5 registered people. How can I accomplish this? I need to have access to all their attributes, for instance, Name, Lastname etc.

This is my route: Route::get('/adminpanel', '[email protected]')->name('adminpanel');

And this is the controller:

    public function index()
    {
        Carbon::setLocale('nl');
        $tijd = Carbon::today();
        $posts = Post::count();
        $users = User::count();
        $replies = Reply::count();

        return view('admin.dashboard', compact('posts', 'users', 'replies', 'tijd'));

    }

They need to be displayed in a table like this:

    <table class="table table-striped">
     <thead>
      <tr>
       <th>ID</th>
       <th>Name</th>
       <th>Lastname</th>
       <th>Email</th>
     </tr>
     </thead>
    <tbody>
    <tr>
     <th scope="row">1</th>
     <td>Rainier</td>
     <td>Laan</td>
     <td>[email protected]</td>
    </tr>
    </tbody>
    </table>

Thanks in advance

Please sign in or create an account to participate in this conversation.