Files
Test-Laravel-Eloquent-Basics/app/Http/Controllers/UserController.php
T
2021-11-16 08:05:39 +02:00

29 lines
643 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\User;
class UserController extends Controller
{
public function index()
{
// TASK: turn this SQL query into Eloquent
// select * from users
// where email_verified_at is not null
// order by created_at desc
// limit 3
$users = User::all(); // replace this with Eloquent statement
return view('users.index', compact('users'));
}
public function show($userId)
{
$user = NULL; // TASK: find user by $userId or show "404 not found" page
return view('users.show', compact('user'));
}
}