PHPackages                             hughcube/laravel-knight - 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. [Database &amp; ORM](/categories/database)
4. /
5. hughcube/laravel-knight

ActiveLibrary[Database &amp; ORM](/categories/database)

hughcube/laravel-knight
=======================

A powerful Laravel extension package providing enhanced Eloquent models, query builders, caching, optimistic locking, middleware, and PostgreSQL array support.

v6.0.160(2mo ago)18.7k↑330.8%1MITPHPPHP &gt;=7.4CI passing

Since Jun 10Pushed 5d agoCompare

[ Source](https://github.com/hughcube/laravel-knight)[ Packagist](https://packagist.org/packages/hughcube/laravel-knight)[ RSS](/packages/hughcube-laravel-knight/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (34)Versions (526)Used By (1)

 Laravel Knight

[](#-laravel-knight-)

 [ ![Test Actions status](https://github.com/hughcube-php/laravel-knight/workflows/Test/badge.svg) ](https://github.com/hughcube-php/laravel-knight/actions?query=workflow%3ATest) [ ![Lint Actions status](https://github.com/hughcube-php/laravel-knight/workflows/Lint/badge.svg) ](https://github.com/hughcube-php/laravel-knight/actions?query=workflow%3ALint) [ ![StyleCI](https://camo.githubusercontent.com/041e0c9edf0201de7c8e2149b5bcd26985eda57f467e15d7aeefd867e5838c9f/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3337333530383235332f736869656c643f6272616e63683d6d6173746572) ](https://styleci.io/repos/373508253) [ ![Latest Version on Packagist](https://camo.githubusercontent.com/c6a00c60bf2ab835ac36808479d1ccc4be57016ff31a15525186f331db25303c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68756768637562652f6c61726176656c2d6b6e696768742e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/hughcube/laravel-knight) [ ![Total Downloads](https://camo.githubusercontent.com/5abd2b8c2c8e2a0aecdea5fff3c9de7c44543cacdd14a3cd2c654a426c80c7e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68756768637562652f6c61726176656c2d6b6e696768742e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/hughcube/laravel-knight) [ ![PHP Version Require](https://camo.githubusercontent.com/892972a8745fb434588b821d26445d29c85e524c4f14f65cf21f1d86c15f892b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68756768637562652f6c61726176656c2d6b6e696768742e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/hughcube/laravel-knight) [ ![License](https://camo.githubusercontent.com/2c697fc13edd3615795598c69bf96d342eaf3cb3cbb03c73caabfdf6b15d458f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68756768637562652d7068702f6c61726176656c2d6b6e696768742e7376673f7374796c653d666c61742d737175617265) ](https://github.com/hughcube-php/laravel-knight/blob/master/LICENSE)

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

[](#introduction)

Laravel Knight is a powerful helper extension for the [Laravel PHP framework](https://github.com/laravel/framework), designed to provide a more robust and efficient development experience. It offers enhanced Eloquent models, query builders, controller utilities, caching mechanisms, optimistic locking, middleware collections, and PostgreSQL array support.

Requirements
------------

[](#requirements)

- PHP 7.4+
- Laravel 6.0+

Features
--------

[](#features)

- **Enhanced Eloquent Models**: Advanced caching mechanisms, optimistic locking, soft deletes, and convenient data manipulation methods
- **Optimized Query Builder**: Extended with `whereLike`, `whereRange`, primary key caching queries, and more
- **PostgreSQL Array Support**: Native PostgreSQL array type handling with `whereIntArrayContains`, `whereTextArrayOverlaps`, etc.
- **Middleware Collection**: Authentication, environment guards, IP restrictions, CORS, HSTS, request logging
- **Controller Utilities**: Action trait with parameter validation, caching, and event dispatching
- **OPcache Management**: Commands for compiling, clearing, and monitoring OPcache
- **Queue Job Tools**: Built-in jobs for ping checks, file cleanup, cache GC, and WeChat token refresh
- **Mixin Extensions**: Extended Collection, Carbon, Str, and Query Builder classes

Installing
----------

[](#installing)

```
composer require hughcube/laravel-knight -vvv
```

Usage
-----

[](#usage)

### 1. Model Enhancements

[](#1-model-enhancements)

Extend `HughCube\Laravel\Knight\Database\Eloquent\Model` to get caching and other utilities.

```
