PHPackages                             khaled-dev/includable - 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. [API Development](/categories/api)
4. /
5. khaled-dev/includable

ActivePackage[API Development](/categories/api)

khaled-dev/includable
=====================

Help the developer to load table in relation by type the name in url

v1.1.0(8y ago)1431MITPHP

Since Nov 2Pushed 8y ago2 watchersCompare

[ Source](https://github.com/khaled-dev/includable)[ Packagist](https://packagist.org/packages/khaled-dev/includable)[ RSS](/packages/khaled-dev-includable/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (0)

Includable
----------

[](#includable)

This Package provides a simple way to load a model relation by require it in the request, You must identify the relation you wish to be included if you require it in the request

### Installation

[](#installation)

Install the package via Composer:

```
$ composer require khaled-dev/includable

```

### Usage

[](#usage)

first use the trait in model:

```
namespace App;

use Khaled7\Includable\Includable;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Includable;

    /**
     * The attributes that are includable,
     * references to a relations method.
     *
     * @var array
     */
    protected $includable = [
        'posts',
        'votes',
    ];

    public function posts()
    {
        return $this->hasMany(Post::class);
    }

    public function votes()
    {
        return $this->hasMany(Vote::class);
    }

    // Not includable, coz not in $includable
    public function subscribes()
    {
        return $this->hasMany(Subscribe::class);
    }
}

```

In controller:

```
// Use to load all includable of all users
User::withRequestIncludes()->get()

// Use to load the includable of this instance
$user = User::first()
$user->loadRequestIncludes();

```

In Request:

```
localhost:8000/users?includes=posts,votes

```

To show the result:

```
// The method `loaded` comes with this package to easily load the included relation
// Use to load the model
$this->loaded('posts');

// Use to load the model to its laravel-resource
PostResource::collection($this->loaded('posts')),

// laravel-resource
// Use to Load an opptional model to its resource
PostResource::collection($this->when($this->loaded('posts'), $this->loaded('posts'))),

// laravel-resource
// Or semply you can use `WhenLoaded` laravel builtin method
PostResource::collection($this->whenLoaded('posts'))

```

> Better to use laravel-resource

> In result it should help you to only include the relations if you really need it, and usually use in APIs.

### License

[](#license)

MIT © Ben Constable 2017.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Total

2

Last Release

3090d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/027bac01d00ff80cdd8256bf3a9777cea03a7c17683276ec6535a03be6b0761d?d=identicon)[khaled-dev](/maintainers/khaled-dev)

---

Top Contributors

[![khaled-dev](https://avatars.githubusercontent.com/u/14126335?v=4)](https://github.com/khaled-dev "khaled-dev (6 commits)")[![ahmed-aliraqi](https://avatars.githubusercontent.com/u/23261109?v=4)](https://github.com/ahmed-aliraqi "ahmed-aliraqi (1 commits)")

---

Tags

apilaravelrelationsloadwithincludeskhaled-devincludable

### Embed Badge

![Health badge](/badges/khaled-dev-includable/health.svg)

```
[![Health](https://phpackages.com/badges/khaled-dev-includable/health.svg)](https://phpackages.com/packages/khaled-dev-includable)
```

###  Alternatives

[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162145.5k1](/packages/joisarjignesh-bigbluebutton)[d-scribe/laraquick

A collection of classes to be extended/used in laravel applications for quick development

371.8k1](/packages/d-scribe-laraquick)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
