PHPackages                             mogody/hyperf-resource - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mogody/hyperf-resource

ActiveLibrary

mogody/hyperf-resource
======================

Api resource classes allow you to expressively and easily transform your models and model collections into JSON

v2.1.0(5y ago)3165MITPHPPHP &gt;=7.2CI failing

Since Jun 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mogody/hyperf-resource)[ Packagist](https://packagist.org/packages/mogody/hyperf-resource)[ RSS](/packages/mogody-hyperf-resource/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (13)Versions (5)Used By (0)

Hyperf API Resources
====================

[](#hyperf-api-resources)

- [Introduction](#introduction)
- [Generating Resources](#generating-resources)
- [Concept Overview](#concept-overview)
    - [Resource Collections](#resource-collections)
- [Writing Resources](#writing-resources)
    - [Data Wrapping](#data-wrapping)
    - [Pagination](#pagination)
    - [Conditional Attributes](#conditional-attributes)
    - [Conditional Relationships](#conditional-relationships)
    - [Adding Meta Data](#adding-meta-data)
- [Resource Responses](#resource-responses)

Introduction
------------

[](#introduction)

When building an API, you may need a transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application's users. Hyperf resource classes allow you to expressively and easily transform your models and model collections into JSON.

Concept Overview
----------------

[](#concept-overview)

> {tip} This is a high-level overview of resources and resource collections. You are highly encouraged to read the other sections of this documentation to gain a deeper understanding of the customization and power offered to you by resources.

Before diving into all of the options available to you when writing resources, let's first take a high-level look at how resources are used within Laravel. A resource class represents a single model that needs to be transformed into a JSON structure. For example, here is a simple `User` resource class:

```
