PHPackages                             whilesmart/laravel-configurations - 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. whilesmart/laravel-configurations

Abandoned → [whilesmart/eloquent-model-configuration](/?search=whilesmart%2Feloquent-model-configuration)Library[Utility &amp; Helpers](/categories/utility)

whilesmart/laravel-configurations
=================================

Laravel package for managing model-specific configurations with type safety and easy persistence

1.0.11(4mo ago)011[1 PRs](https://github.com/whilesmartphp/eloquent-model-configs/pulls)MITPHPCI passing

Since Jul 9Pushed 2mo agoCompare

[ Source](https://github.com/whilesmartphp/eloquent-model-configs)[ Packagist](https://packagist.org/packages/whilesmart/laravel-configurations)[ RSS](/packages/whilesmart-laravel-configurations/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (32)Used By (0)

Whilesmart Eloquent Model Configuration Package
===============================================

[](#whilesmart-eloquent-model-configuration-package)

This Laravel package provides a complete configuration solution ready to be integrated into your application.

Features
--------

[](#features)

- **NoSQL-like Flexibility:** Add schema-less dynamic attributes to any Eloquent model without database migrations
- **Type-Safe Storage:** Supports strings, integers, arrays, JSON, dates with automatic type casting via `ConfigValueType` enum
- **Polymorphic Relationships:** Any model can have configurations through a single, flexible relationship
- **Ready-to-use endpoints:** Complete API for managing configurations
- **OpenAPI documentation:** Automatically generated documentation using PHP attributes
- **Configuration file:** Easily customize settings
- **Laravel agnostic considerations:** designed with future framework agnosticism in mind

Development
-----------

[](#development)

This package includes a Docker development environment and Makefile for easy development.

### Quick Start

[](#quick-start)

```
# Start the development environment
make up

# Install dependencies
make install

# Run tests
make test

# Run code formatter
make pint

# Show all available commands
make help
```

### Available Make Commands

[](#available-make-commands)

- `make up` - Start Docker containers
- `make down` - Stop Docker containers
- `make install` - Install dependencies
- `make test` - Run tests
- `make pint` - Run Laravel Pint code formatter
- `make lint` - Alias for pint
- `make fresh` - Fresh start (down, up, install)
- `make setup` - Complete setup with tests
- `make check` - Run all checks (formatting + tests)
- `make shell` - Access container shell

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

[](#installation)

### 1. Require the package

[](#1-require-the-package)

```
composer require whilesmart/eloquent-model-configuration
```

### 2. Publish the configuration and migrations:

[](#2-publish-the-configuration-and-migrations)

You do not need to publish the migrations and configurations except if you want to make modifications. You can choose to publish the migrations, routes, controllers separately or all at once.

#### 2.1 Publishing only the routes

[](#21-publishing-only-the-routes)

Run the command below to publish only the routes.

```
php artisan vendor:publish --tag=model-configuration-routes
php artisan migrate
```

The routes will be available at `routes/model-configuration.php`. You should `require` this file in your `api.php` file.

```
    require 'model-configuration.php';
```

#### 2.2 Publishing only the migrations

[](#22-publishing-only-the-migrations)

+If you would like to make changes to the migration files, run the command below to publish only the migrations.

```
php artisan vendor:publish --tag=model-configuration-migrations
php artisan migrate
```

The migrations will be available in the `database/migrations` folder.

#### 2.3 Publish only the controllers

[](#23-publish-only-the-controllers)

By default the controllers assign the device to the currently logged in user. If you would like to assign the device to another model, you can publish the controllers and make the necessary changes to the published file.
To publish the controllers, run the command below

```
php artisan vendor:publish --tag=model-configuration-controllers
php artisan migrate
```

The controllers will be available in the `app/Http/Controllers` directory. Finally, change the namespace in the published controllers to your namespace.

#### 2.4 Publish the documentation

[](#24-publish-the-documentation)

To publish the openapi documentation, run the command below

```
php artisan vendor:publish --tag=model-configuration-docs
```

The documentation will be available at `app/Http/Documentation`

#### 2.5 Publish everything

[](#25-publish-everything)

To publish the migrations, routes and controllers, you can run the command below

```
php artisan vendor:publish --tag=model-configuration
php artisan migrate
```

#### Note: See section 2.1 above to make the routes accessible

[](#note-see-section-21-above-to-make-the-routes-accessible)

#### 2.6 Middleware configuration

[](#26-middleware-configuration)

The default controller gets the authenticated user from the `Request` object. The default routes must be placed in an auth middleware. Set your auth middleware in the `config/model-configuration.php` file.

```
