perrotin/smart-select

A tool that will allow you set default select to your model and create the database user with the limited grants.
1,338
Install
composer require perrotin/smart-select
Latest Version:0.1.2
PHP:^8.0
License:MIT
Last Updated:Mar 12, 2026
Links: GitHub  ·  Packagist
Maintainer: Perrotin

Smart select

Install

Install the package

composer require perrotin/smart-select

followed by

php artisan vendor:publish --provider="SmartSelect\Providers\SmartSelectServiceProvider"

for developement

If you wish to update the package, a good way is to update the repository and replace it with

"repositories": [
    {
        "type": "path",
        "url": "./packages-folder/smartselect",
        "options": {
            "symlink": true
        }
    }
],

How to use

Set up the package

In every model you want, you must :

  • use the HasDefaultSelect trait
  • use the HasDefaultSelectColumns interface
  • set the getGrantColumns()method.

For example


namespace App\Models;

use SmartSelect\Contracts\HasDefaultSelectColumns;
use SmartSelect\Traits\HasDefaultSelect;

class User extends Model implements HasDefaultSelectColumns
{

	use HasDefaultSelect;

	protected $table = 'users';

	public function getGrantColumns(): array
    {
        return [
			'select' => ['id','name','created_at','updated_at'],
            'insert' => ['email', 'name'] // $this->fillable
		];
    }
}

Configure it

use commands

TODO

  • Testing
  • Config option to execute grant access depending of environment
  • ...

Related Packages

zara-4/laravel-lazy-mysql

A lazy mysql based Eloquent model and Query builder for Laravel

7,985 10
phoenixgao/laravel-postgres-extended-schema

Laravel database schema extended, added some PostgreSql features

2,250 6
jaschweder/laravel-sqlanywhere

A Sybase driver based Eloquent model and Query builder for Laravel 4

490 0
nicolaslopezj/searchable

Eloquent model search trait.

3,012,224 1,994
ort-interactive-gmbh/laravel-couchbase

A Couchbase based Eloquent model and Query builder for Laravel

348 41