How to generate API Resources in Laravel

php artisan make:resource UserResource
return new UserResource(User::findOrFail($id));
php artisan make:resource UserCollection
return new UserCollection(User::all());