PHPackages                             willishq/laravel-components - 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. willishq/laravel-components

AbandonedArchivedLibrary

willishq/laravel-components
===========================

Components for Laravel 5

1.4(11y ago)3581MITPHPPHP &gt;=5.4.0

Since Sep 25Pushed 11y agoCompare

[ Source](https://github.com/willishq/laravel-components)[ Packagist](https://packagist.org/packages/willishq/laravel-components)[ RSS](/packages/willishq-laravel-components/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (7)Used By (1)

Laravel components
==================

[](#laravel-components)

[![Build Status](https://camo.githubusercontent.com/6b0cad62c73d2496b780b1339a9b3de57efb8aac9287a60f12ef4c01a72d7cf1/68747470733a2f2f7472617669732d63692e6f72672f77696c6c697368712f6c61726176656c2d636f6d706f6e656e74732e737667)](https://travis-ci.org/willishq/laravel-components)

These are components which I use frequently when creating and maintaining a Laravel project, and two traits which I keep copying from project to project.

Installation
------------

[](#installation)

Grab this package through Composer:

```
{
    "require" {
        "willishq/laravel-components": "1.*"
    }
}
```

Traits
------

[](#traits)

The two traits provided are the `EventableTrait` and the `RetrievableTrait`.

### EventableTrait Usage

[](#eventabletrait-usage)

The `EventableTrait` is used in tandem with `laracasts\commander` package and enables you to raise and dispatch events directly on your objects (such as Eloquent models), along with firing events when the object is destroyed.

`MyModel.php`

```
use Willishq\LaravelComponents\EventableTrait;
use Illuminate\Database\Eloquent\Model;

class MyModel extends Model {
    use EventableTrait;
    /**
     * Whether to dispatch remaining events when the object is tore down
     *
     * @var bool
     */
    protected $dispatchOnDestruct = true;
}
```

```
$model = new MyModel;

$model->raise(new ModelWasInstantiatedEvent($model));
```

if you left the model like this, the event would be fired automatically by the `__destruct` method, or you can call `$model->dispatchEvents();` which would dispatch all remaining events.

### RetrievableTrait Usage

[](#retrievabletrait-usage)

The `RetrievableTrait` enables you to retrieve specific `public` keys from your objects. It provides you with two methods, `retrieveOnly` and `retrieveExcept`

```
use Willishq\LaravelComponents\RetrievableTrait;
class Book {
    use RetrievableTrait;

    public $title;
    public $author;
    public $publish_date;
    public $blurb;

    public function __construct($title, $author, $publish_date, $blurb)
    {
        $this->title = $title;
        $this->author = $author;
        $this->publish_date = $publish_date;
        $this->blurb = $blurb;
    }
}
```

```
$book = new Book('My Amazing Book', 'Andrew Willis', '19/04/2020', 'Andrew was a normal person from Sunderland. you\'ll never believe what happened next.');

$fields = $book->retrieveOnly('title', 'author');
// ['title' => 'My Amazing Book', 'author' => 'Andrew Willis']

$fields = $book->retrieveExcept('blurb');
// ['title' => 'My Amazing Book', 'author' => 'Andrew Willis', '19/04/2020']
```

I have found this useful when dealing with DTO's.

Packages
--------

[](#packages)

Please be sure to add the following to your `config/app.php` file to use the packages!

### Service Providers:

[](#service-providers)

```
        // Laravel DebugBar
        'Barryvdh\Debugbar\ServiceProvider',
        // Laracasts Commander package
        'Laracasts\Commander\CommanderServiceProvider',
        // Laracasts Flash package
        'Laracasts\Flash\FlashServiceProvider',
        // Laravel 5 requires you to include the HTML package yourself
        'Illuminate\Html\HtmlServiceProvider',
```

### Facades:

[](#facades)

```
        'Debugbar'  => 'Barryvdh\Debugbar\Facade',
        'Form'      => 'Illuminate\Html\FormFacade',
        'Flash'     => 'Laracasts\Flash\Flash',
```

Other packages included are: `laracasts/presenter` and `league/fractal`.

Documentation for all of the packages included can be found here:

- [fractal.thephpleague.com](http://fractal.thephpleague.com)
- [github.com/laracasts/Presenter](https://github.com/laracasts/Presenter)
- [github.com/laracasts/flash](https://github.com/laracasts/flash)
- [github.com/laracasts/commander](https://github.com/laracasts/Commander)
- [github.com/barryvdh/laravel-debugbar](https://github.com/barryvdh/laravel-debugbar)

For development and testing, I suggest you use `codeception/codeception`, `laracasts/testdummy` and `fzaninotto/faker`

- [github.com/laracasts/TestDummy](https://github.com/laracasts/TestDummy)
- [github.com/fzaninotto/faker](https://github.com/fzaninotto/faker)
- [github.com/codeception/codeception](https://github.com/codeception/codeception)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity62

Established project with proven stability

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 ~1 days

Total

5

Last Release

4240d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e16a979f062ee9a01f53d23dc34dd4fcfc0ac32df859827174bc7782d2e1aa5?d=identicon)[willishq](/maintainers/willishq)

---

Tags

laravellaravel5setup

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/willishq-laravel-components/health.svg)

```
[![Health](https://phpackages.com/badges/willishq-laravel-components/health.svg)](https://phpackages.com/packages/willishq-laravel-components)
```

###  Alternatives

[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)

PHPackages © 2026

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