PHPackages                             ollieread/laravel-toolkit - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ollieread/laravel-toolkit

Abandoned → [sprocketbox/laravel-toolkit](/?search=sprocketbox%2Flaravel-toolkit)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

ollieread/laravel-toolkit
=========================

v3.3.1(8y ago)77441MITPHPPHP ^7.2

Since Jan 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ollieread/toolkit)[ Packagist](https://packagist.org/packages/ollieread/laravel-toolkit)[ RSS](/packages/ollieread-laravel-toolkit/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (1)Versions (11)Used By (0)

Laravel Toolkit
===============

[](#laravel-toolkit)

[![Latest Stable Version](https://camo.githubusercontent.com/d3cd9a4b9fad22c9b1579118fe8f76866ddcbee6ab02d854b74d471d3991cacf/68747470733a2f2f706f7365722e707567782e6f72672f6f6c6c6965726561642f6c61726176656c2d746f6f6c6b69742f762f737461626c652e706e67)](https://packagist.org/packages/ollieread/laravel-toolkit) [![Total Downloads](https://camo.githubusercontent.com/c758dd7e0271ab53618d1cf1dea13a6bb1ab098722f51143a755b66724be8ddf/68747470733a2f2f706f7365722e707567782e6f72672f6f6c6c6965726561642f6c61726176656c2d746f6f6c6b69742f646f776e6c6f6164732e706e67)](https://packagist.org/packages/ollieread/laravel-toolkit) [![Latest Unstable Version](https://camo.githubusercontent.com/187e087bb90ad96220319a160c21466811ec48a11aa44640e7cbdaed65b12d3e/68747470733a2f2f706f7365722e707567782e6f72672f6f6c6c6965726561642f6c61726176656c2d746f6f6c6b69742f762f756e737461626c652e706e67)](https://packagist.org/packages/ollieread/laravel-toolkit) [![License](https://camo.githubusercontent.com/40d2c88baa208e0c9a8aec61230f6cccfb8d44ba4499c06623e5868f65de9e67/68747470733a2f2f706f7365722e707567782e6f72672f6f6c6c6965726561642f6c61726176656c2d746f6f6c6b69742f6c6963656e73652e706e67)](https://packagist.org/packages/ollieread/laravel-toolkit)

- **Laravel**: 5.5
- **PHP**: 7.1+
- **Author**: Ollie Read
- **Author Homepage**:

This toolkit aims to simplify the day to day development of Laravel applications. It has some basic functionality and modifications that I find myself using in almost every project.

Versions
--------

[](#versions)

VersionPHPLaravelv1&gt;= 5.6.45.3v2&gt;= 5.6.45.4&lt; v3.2&gt;= 7.15.4=&gt; v3.2&gt;= 7.15.5+Installation
------------

[](#installation)

Package is available on [Packagist](https://packagist.org/packages/ollieread/laravel-toolkit), you can install it using Composer.

```
composer require ollieread/laravel-toolkit

```

Usage
-----

[](#usage)

There are four pieces of functionality offered by this toolkit.

### Eloquent

[](#eloquent)

This toolkit provides two different scopes, packaged up. Please note, these only provided additional functionality to aid you, you have to handle the database schema side yourself.

#### Enabled

[](#enabled)

If you have a model that has an enabled/active state, you can add this functionality by using the following contract and trait.

```
Ollieread\Toolkit\Eloquent\Enabled\EnabledContract
Ollieread\Toolkit\Eloquent\Enabled\EnabledTrait

```

Adding these to your model will automatically add the following scope.

```
Ollieread\Toolkit\Eloquent\Enabled\EnabledScope

```

Your enable state column must be a boolean/int field. If it is called anything but `enabled`you can override the property provided by the trait.

```
protected $enabled = 'enabled';

```

Once all of this has been added, querying this model will only return the enabled entries by default. To return all, use the following method, much like soft deletes.

```
withDisabled()

```

If you only want disabled, use the following.

```
disabled()

```

#### Order

[](#order)

If you have a model that is orderable, you can add this functionality by adding the following trait and contract to your model.

```
Ollieread\Toolkit\Eloquent\Order\OrderContract
Ollieread\Toolkit\Eloquent\Order\OrderTrait

```

This will add the following global scope.

```
Ollieread\Toolkit\Eloquent\Order\OrderScope

```

Your queries will now be ordered by the order field, the name of which is provided by overriding the property provided by the trait. This column must be an integer.

```
protected $order = 'order';

```

You can change the order of a given model by using the following self explanatory macros.

```
moveUp()
moveDown()
moveToTop()
moveToBottom()

```

Moving a row up, down, to the top or to the bottom, will correct the order value for all other rows. The values of the column will be numeric, with the top being 0.

### Base Validator

[](#base-validator)

The base validator is a step away from Form Requests. This is primarily due to my dislike of having the HTTP layer validate data, which is not its job.

To create a validator, extend the following class;

```
Ollieread\Toolkit\Validators\BaseValidator

```

Next you define your rules with the following method;

```
public function getRules(): array {
    return [];
}

```

You can also optionally override the following method, to provide custom messages;

```
public function getMessages(): array {
    return [];
}

```

To validate your data, you can do the following;

```
$myValidator = MyValidator::validate($arrayOfData[, $model])

```

The second argument allows you to pass in a model (useful when validating update forms). This model is available within the `getRules()` and `getMessages()` methods as `$this->model`.

A Laravel validation exception is thrown automatically should validation fail.

To return an instance of the underlying validator you can do the following;

```
$myValidator->validator();

```

### Base Repository

[](#base-repository)

The base repository is an abstract class that I have all of my repositories extend. This repository by default is designed to work with Eloquent.

To create a repository, extend the following class;

```
Ollieread\Toolkit\Repositories\BaseRepository

```

To set the model for your repository, add the following property;

```
property $model = MyModel::class;

```

#### Make (protected)

[](#make-protected)

To retrieve a new instance of your model, call the following;

```
$this->make()

```

#### Query (protected)

[](#query-protected)

To retrieve a new query on a new instance of your model, call the following;

```
$this->query()

```

This method primarily exists as helper (calls `$this->make()->newQuery()`) so that my IDE doesn't cry at me.

#### Get ID (protected)

[](#get-id-protected)

To retrieve the id from a variable that is either the id, or an instance of the model, call the following;

```
$this->getId($id)

```

#### Delete

[](#delete)

This is a base deletion method, if you pass in an ID it uses a query, if you pass in a model it calls the helper. To access it, call the following;

```
$repository->delete($model)

```

#### Get One By

[](#get-one-by)

This a method to retrieve a single row by either a key =&gt; value, or an array of key =&gt; values, to use it, call the following;

```
$repository->getOneBy($key, $value)
$repository->getOneBy([$key1 => $value1, $key2 => $value2])

```

This method is available as a magic method, so you can do the following;

```
$repository->getOneById($value)

```

#### Get By

[](#get-by)

This method is the same as the above, except it will return all matched results, rather than just one. To use it, call the following;

```
$repository->getBy($key, $value)
$repository->getBy([$key1 => $value1, $key2 => $value2])

```

This method is available as a magic method, so you can do the following;

```
$repository->getByDate($value)

```

#### Transaction (static)

[](#transaction-static)

To start a transaction, call the following;

```
MyRepository::transaction(function () {
    $this->somethingSomething();
    return true;
});

```

This method behaves exactly the same way as `DB::transaction()`.

### Tips

[](#tips)

For simplicity, I like to add the method definitions to the class level phpdoc block of my repositories, like so;

```
/**
 * Class MyRepository
 *
 * @method MyModel make()
 * @method null|MyModel getOneById(int $id)
 *
 * @package My\Repositories
 */

```

### User Model

[](#user-model)

To gain access to a password setting mutator (automatically hashes) and a helper method `isPassword($password)` to compare passwords, have your user models extend the following;

```
Ollieread\Toolkit\Models\User

```

This model extends the default auth user, so you still retain that functionality.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~53 days

Recently: every ~86 days

Total

9

Last Release

3020d ago

Major Versions

v1.0.0 → v2.0.02017-01-28

v2.0.1 → v3.0.02017-04-12

PHP version history (3 changes)v1.0.0PHP &gt;=5.6.4

v3.0.0PHP ^7.1

v3.3.1PHP ^7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/469515?v=4)[Ollie Read](/maintainers/ollieread)[@ollieread](https://github.com/ollieread)

---

Top Contributors

[![ollieread](https://avatars.githubusercontent.com/u/469515?v=4)](https://github.com/ollieread "ollieread (20 commits)")

### Embed Badge

![Health badge](/badges/ollieread-laravel-toolkit/health.svg)

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

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[crumbls/layup

A visual page builder plugin for Filament 5 — Divi-style grid layouts with extensible widgets.

592.7k2](/packages/crumbls-layup)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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