Store Extra Columns as JSON With Laravel Overflow

Store Extra Columns as JSON With Laravel Overflow

Laravel Overflow is a package by Logan H. Craft that allows adding an overflow column to a form request. An overflow column contains request values in a JSON or TEXT column in the database.

Defining an overflow column involves using a form request with the package’s Overflowable trait:

use Illuminate\Foundation\Http\FormRequest;
use CraftLogan\LaravelOverflow\Overflowable;

class OverflowFormRequest extends FormRequest
{
    use Overflowable;
    public $table = 'test_models';
    public $overflow_column = 'properties';

    // ...
}

The trait provides some methods for separating table columns from database table columns:

// Get JSON-encoded overflow data
$model->properties = $request->overflow();

// Get table columns and overflow in one array
$request->allWithOverflow();

// Get database columns that intersect with $request->all() keys
$request->getColumns();

You can learn more about this package, get full installation instructions, and view the source code on GitHub at CraftLogan/Laravel-Overflow.

Filed in: News / packages
Laravel News Partners

Laravel Jobs

PHP Developer - Full time w/ benefits, US Only
Northern Virginia or Remote (US Only)
Guidance Residential
Full Stack Developer
Remote
Wehaa.com
Laravel API Developer
Las Vegas, NV (Must work on-site)
V Shred
Laravel Developer (Vue, SQL Server)
Remote
World Trade Organization
Web Application Developer (Vue.js & Laravel)
Remote
Apero Creative Development

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.