PHPackages                             diviky/bright - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. diviky/bright

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

diviky/bright
=============

Framework extension

v7.0.30(3w ago)128.4k11[4 PRs](https://github.com/diviky/bright/pulls)1MITPHPPHP ^8.3 || ^8.4CI failing

Since Oct 20Pushed 3w ago1 watchersCompare

[ Source](https://github.com/diviky/bright)[ Packagist](https://packagist.org/packages/diviky/bright)[ Docs](https://github.com/diviky/bright)[ RSS](/packages/diviky-bright/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (41)Versions (285)Used By (1)

An extension to laravel for quick develpment
============================================

[](#an-extension-to-laravel-for-quick-develpment)

Install
-------

[](#install)

```
    composer require diviky/bright

```

##### Filter the query with input values

[](#filter-the-query-with-input-values)

```
$filters = [];
// $query->whereRaw('date(created_at) = ?', ['2019-10-12'])
$filters[] = ['date[created_at]' => date('Y-m-d')];

// $query->whereDateBetween('created_at between ? and ? ', ['2019-10-12', '2019-10-22'])
$filters[] = ['range[created_at]' => date('Y-m-d') .' - '. date('Y-m-d')];

// $query->whereBetween('created between ? and ? ', [strtotime('-1 day'), time()])
$filters[] = ['timestamp[created]' => date('Y-m-d') .' - '. date('Y-m-d')];

//
$filters[] = ['unixtime[created]' => date('Y-m-d') .' - '. date('Y-m-d')];
$filters[] = ['between[created]' => date('Y-m-d') .' - '. date('Y-m-d')];

$filters[] = ['filter[name]' => 'bright']; // $query->where('name', '=', 'bright')
$filters[] = ['filter[first_name|last_name]' => 'bright']; // $query->where('first_name', '=', 'bright')->orWhere()
$filters[] = ['lfilter[name]' => 'bright']; // $query->where('name', 'like', '%bright%')
$filters[] = ['rfilter[name]' => 'bright']; // $query->where('name', 'like', 'bright%')
$filters[] = ['efilter[name]' => 'bright']; // $query->where('name', 'like', '%bright')

$rows = DB::table('users')
    ->filter($filters)
    ->get();
```

Database Filter
===============

[](#database-filter)

`filter` method used to filter the database columns in query builder. it accepts `requets` object as `array`.

Avaliable filters

`filter[]` uses the `$builder->where($column, $value)`. uses array key as column name and value as value. ex: `filter[column]='value'`

`lfilter[]` uses the `$builder->where($column, '%'.$value.'%')` with like match. uses array key as column name and value as value. ex: `lfilter[column]='value'`

use the `|` notation to filter or condition. ex: `filter[comments|title]=xxx`use the `:` notation to filter with relation table. ex: `filter[posts:title]=xxx`use the `.` notation to filter the table alias in join query. ex: `filter[comments.title]=xxx`use the `scope[]` to filter the model scopes. ex: `scope[status]=1` will run `$builder->status(1)`use `parse[]` to DSL Parser for a filter query langague. Example queries in this language:

- `price = 100`
- `price != 100`
- `price > 100`
- `price < 100`
- `price = 100`
- `name =~ "brig%"`
- `price > 100 AND active = 1`
- `status = "pending" OR status = "approved"`
- `product.price > 100 AND category.id = 7`
- `product:price > 100 AND category:id = 7`
- `name =~ "Foo%"`
- `created_at > "2017-01-01" and created_at < "2017-01-31"`
- `status = 1 AND (name = "PHP Rocks" or name = "I ♥ PHP")`

Model Relations
---------------

[](#model-relations)

Return single model with merged attributes from relations

flattern
--------

[](#flattern)

The `flattern($except, $exlcude)` method merge the key and values of releations into primary model attributes and return the combines attributes. Releation keys will overwrite the primary keys if they are same.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->flattern();
});
```

flat
----

[](#flat)

The `flat($except, $exlcude)` method merge the key and values of releations into primary model attributes and return the combines attributes.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->flat();
});
```

some
----

[](#some)

The `some($keys)` method get few keys from the relationships and primary model.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->some(['id', 'author.name']);
});
```

except
------

[](#except)

The `except($keys)` method get few keys from the relationships and primary model.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->except(['author.id']);
});
```

merge
-----

[](#merge)

The `merge($keys)` method add additional key value pairs to model attributes.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->merge(['extra' => 'value']);
});
```

concat
------

[](#concat)

The `concat($keys)` method add relations key values to attributes.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->concat(['author.id','author.name']);
});
```

combine
-------

[](#combine)

The `combine($keys)` method to merge and contact the releations and attributes.

```
use App\Models\User;

$rows = Book::with('author')->get();

$rows->transform(function($row) {
    return $row->combine(['author.id', 'author.name']);
});
```

Eloquent: Collections
=====================

[](#eloquent-collections)

flatterns
---------

[](#flatterns)

The `flatterns($except, $exlcude)` method merge the key and values of releations into primary model attributes and return the combines attributes. Releation keys will overwrite the primary keys if they are same.

```
use App\Models\User;

$books = Book::with('author')->get();

$books = $books->flatterns($except, $exclude);
```

flats
-----

[](#flats)

The `flats($except, $exlcude)` method merge the key and values of releations into primary model attributes and return the combines attributes.

```
use App\Models\User;

$books = Book::with('author')->get();

$books = $books->flats($except, $exclude);
```

few
---

[](#few)

The `few($keys)` method get few keys from the relationships and primary model.

```
use App\Models\User;

$books = Book::with('author')->get();

$books = $books->few(['id', 'author.name']);
```

Flatten Relations
-----------------

[](#flatten-relations)

Return single model with merged attributes from relations

```
// except the relations from merge
$model = $model->flatten($except);

// Take some keys
$model = $model->some(['id']);

// Take except
$model = $model->except(['id']);

// Append keys to attributes
$model = $model->merge(['id' => 1]);

// Apped relation keys to attributes
$model = $model->concat(['relation.id']);

// combination of merge and contact
$model = $model->combine(['relation.id']);
```

### Sorting task

[](#sorting-task)

```

    ...

```

```
    if ($task == 'sorting') {
        $sorting = $this->input('sorting');
        $this->get('resolver')->getHelper('speed')->sorting('table', $sorting, 'id');

        return [];
    }
```

### Builder Extended Methods

[](#builder-extended-methods)

#### Search multiple columns and relations

[](#search-multiple-columns-and-relations)

```
Post::whereLike(['name', 'text', 'author.name', 'tags.name'], $searchTerm)->get();
```

##### Iterating results

[](#iterating-results)

If you like fetch all the rows with chunks and modify using callaback

```
$rows = DB::table('large_table')->iterate(1000);

$rows = DB::table('large_table')->iterate(1000, function($row) {

    return $row;
});
```

##### Get results from multiple tables

[](#get-results-from-multiple-tables)

If you have data in multiple tables, want to retrive table after table with pagination

```
$rows = DB::tables(['roles', 'roles1', 'roles2'])->complexPaginate();
```

##### Cache the query results

[](#cache-the-query-results)

If you want to cache the results

```
$rows = DB::table('uses')
    ->remember($minutes, $cache_key)
    ->get();

$rows = DB::table('uses')
    ->rememberForever($cache_key)
    ->get();
```

##### Delete from select query

[](#delete-from-select-query)

```
$rows = DB::table('users')
    ->filter($filters)
    ->deletes();
```

```
$rows = DB::table('users')
    ->whereDateBetween('created_at', [date(), date()])
    ->get();
```

##### Get Trashed &amp;&amp; Non Trashed

[](#get-trashed--non-trashed)

Get non deleted items

```
$rows = DB::table('users')
    ->withOutTrashed()
    ->get();
```

Get only deleted items

```
$rows = DB::table('users')
    ->onlyTrashed()
    ->get();
```

##### Raw Expressions

[](#raw-expressions)

```
$rows = DB::table('orders')
    ->groupByRaw(['username']);
    ->groupByRaw('price * ? as price_with_tax', [1.0825]);
    ->get()
```

```
$rows = DB::table('orders')
    ->selectRaw(['max(price)', 'order_id']);
    ->groupByRaw('price * ? as price_with_tax', [1.0825]);
    ->get()
```

```
$rows = DB::table('orders')
    ->selectRaw(['max(price)', 'order_id']);
    ->whereBetweenRaw('max(price)', [1.0825, 2]);
    ->get()
```

##### Ordering

[](#ordering)

```
$rows = DB::table('orders')
    ->ordering($data, ['order_id' => 'desc']);
    ->groupByRaw('price * ? as price_with_tax', [1.0825]);
    ->get()
```

##### Timestamps

[](#timestamps)

Set the timestamps 'created\_at`and`updated\_at`for insert and`updated\_at` for update

```
    $result = DB::table('orders')
        ->timestamps()
        ->insert($values)
```

```
    $result = DB::table('orders')
        ->timestamps()
        ->update($values)
```

```
    $result = DB::table('orders')
        ->timestamps(false)
        ->update($values)
```

```

      Search Employee

```

```

      Search Employee

```

```

      Search Employee

```

```

      Search Employee

```

```

      Search Country

      Search State

```

- `:id` will be replaced with country id to get states list

Attributes
----------

[](#attributes)

Custom attributes used in controllers to configure view, resources and layouts

Avaliable attributes

```
use Diviky\Bright\Attributes\View;
use Diviky\Bright\Attributes\ViewPaths;
use Diviky\Bright\Attributes\ViewNamespace;
use Diviky\Bright\Attributes\Resource;
use Diviky\Bright\Attributes\ResourceCollection;

#[View('name', 'layout')]
#[View('none')] //No view will be rendered
#[ViewPaths([__DIR__.'views'])]
#[ViewNamespace("package")]
#[Resource('Resources/PostResource', 'post')]
#[ResourceCollection('Resources/PostResource', 'posts')]

```

```
#[View('name', 'layout')] // by default method name has view name
public function index(Request $request)
{
    $data = $request->all();

    $rows = Post::filter($data)
        ->ordering($data, ['ordering' => 'asc'])
        ->paginate();

    return [
        'rows' => $rows,
    ];
}
```

JS files
--------

[](#js-files)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance95

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor1

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

Total

279

Last Release

24d ago

Major Versions

v2.2.8 → v3.0.52023-02-27

3.x-dev → v4.0.12023-07-26

4.x-dev → v5.0.02024-07-31

v5.0.34 → v6.0.02025-04-01

v6.0.22 → v7.0.02025-08-03

PHP version history (9 changes)v1.0.1PHP &gt;=7.1

v1.0.5PHP &gt;=7.3

v2.0.3PHP &gt;=7.4

v2.1.8PHP ^8.0|^8.1

v2.1.33PHP ^8.1

v4.0.1PHP ^8.1|^8.2

v5.0.0PHP ^8.2

v5.0.4PHP ^8.2 || ^8.3 || ^8.4

v5.0.24PHP ^8.3 || ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/99c172c42e19c2ad0db03c0596a00eb21047df990ba405bb2d1fd57204eb2c2f?d=identicon)[sankar.suda](/maintainers/sankar.suda)

---

Top Contributors

[![sankarsuda](https://avatars.githubusercontent.com/u/798414?v=4)](https://github.com/sankarsuda "sankarsuda (552 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (30 commits)")[![nagasatishkadiyam](https://avatars.githubusercontent.com/u/64677785?v=4)](https://github.com/nagasatishkadiyam "nagasatishkadiyam (11 commits)")[![sushmashivakavi](https://avatars.githubusercontent.com/u/141399532?v=4)](https://github.com/sushmashivakavi "sushmashivakavi (3 commits)")[![neha-kiran](https://avatars.githubusercontent.com/u/137485171?v=4)](https://github.com/neha-kiran "neha-kiran (2 commits)")[![midhun-mbt](https://avatars.githubusercontent.com/u/140140395?v=4)](https://github.com/midhun-mbt "midhun-mbt (1 commits)")[![bedhprasad29](https://avatars.githubusercontent.com/u/90366230?v=4)](https://github.com/bedhprasad29 "bedhprasad29 (1 commits)")[![bedh29](https://avatars.githubusercontent.com/u/99157294?v=4)](https://github.com/bedh29 "bedh29 (1 commits)")

---

Tags

laravelsecurityaclpermission

### Embed Badge

![Health badge](/badges/diviky-bright/health.svg)

```
[![Health](https://phpackages.com/badges/diviky-bright/health.svg)](https://phpackages.com/packages/diviky-bright)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[sourceboat/laravel-static-permission

Define laravel permissions and roles by code

1018.0k](/packages/sourceboat-laravel-static-permission)

PHPackages © 2026

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