mirror of
https://github.com/10h30/Test-Laravel-Eloquent-Basics.git
synced 2026-06-05 15:07:45 +09:00
29 lines
643 B
PHP
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'));
|
|
}
|
|
}
|