New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ybr-nx/laravel-mariadb

Add MariaDB JSON select support to Laravel
480,118 96
Install
composer require ybr-nx/laravel-mariadb
Latest Version:1.0.20
Laravel:5 · 6
License:EUPL-1.2
Last Updated:Sep 11, 2019
Links: GitHub  ·  Packagist
Maintainer: ybr-nx

laravel-mariadb

Add MariaDB JSON support to Laravel. Requires at least MariaDB 10.2.3 (and 10.2.7 to use ->json() migrations)

Install

Using composer:

$ composer require ybr-nx/laravel-mariadb
Configure (only Larvel 5.3 and 5.4)

Include MariaDBServiceProvider in your config/app.php:

'providers' => [
    /*
     * Package Service Providers...
     */
    YbrNX\MariaDB\MariaDBServiceProvider::class,
]

set driver in database configuration to mariadb

'defaultconnection' => [
    'driver' => 'mariadb',
Added functionality
Migration

Adds needed validation to json fields during migrations

$table->json('field') //CHECK (JSON_VALID(field))
$table->json('field')->nullable() //CHECK (field IS NULL OR JSON_VALID(field))
Query builder

Builds json select statements to work with MariaDB

$query->where('somejson->something->somethingelse', 2)
DB::table('sometable')->select('sometable.somedata', 'sometable.somejson->somedata as somejsondata')

And also JSON_SET() works in MariaDB as in MySQL 5.7

DB::table('sometable')->where('somejson->somedata', $id)->update(['somejson->otherdata' => 'newvalue']);

NB There is bug in MariaDB < 10.2.8 JSON_EXTRACT() behaviour function. It's fixed in MariaDB 10.2.8: https://jira.mariadb.org/browse/MDEV-12604

//works with string in MySQL & MariaDB 10.2.8
$query->where('somejson->something->somethingelse', 'somedata')

//works with string in MariaDB < 10.2.8
$query->where('somejson->something->somethingelse', '"somedata"') 

Related Packages

hedronium/jables

Write your Laravel Database Schema in JSON.

105 79
scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

28,927,693 593
dvrtech/schema-tools

Laravel package for JSON/CSV schema analysis and database structure generation

10,857 0
gigerit/laravel-mysql-optimizer

A laravel package that optimizes mysql/mariadb database tables.

2,816 3
jfadich/json-property

Transform an object property into an enhanced array

458 3

Version History

Version Released Laravel License
1.0.20 >=5.3 EUPL-1.2
1.0.19 5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.* EUPL-1.2
1.0.18 5.3.*|5.4.*|5.5.*|5.6.*|5.7.* EUPL-1.2
1.0.17 5.3.*|5.4.*|5.5.*|5.6.*|5.7.* EUPL-1.2
1.0.16 5.3.*|5.4.*|5.5.*|5.6.* EUPL-1.2