muharremozdemir
public function index()
{
$users = User::paginate();
return UserResource::collection($users);
}
public function show($id)
{
$user = User::findOrFail($id);
return UserResource::make($user);
}
app/Http/Resources/UserResource.php:
public function toArray($request)
{
// $this burada yüklenen User bilgilerini de içerir:
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
];
}