Homepage
Main navigation
Main content
Additional information
October Tricks
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
October CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
Fields that are declared as `jsonable` are stored as JSON string in a single database column. If you declare this column as `JSON` type in your database you can use Laravel's [JSON where clauses](https://laravel.com/docs/5.5/queries#json-where-clauses) to query the structured data. You need to be using a database that supports JSON columns (MySQL 5.7+ or MariaDB 10.2+). ```php // In your migration Schema::create('your_table', function (Blueprint $table) { $table->increments('id'); $table->json('jsonable_field'); // Declare as JSON // ... }); ``` Basic queries are supported on Laravel 5.5. ```php $users = DB::table('users') ->where('preferences->dining->meal', 'salad') ->get(); ``` If you need advanced JSON features you have to fall back to raw queries. ```php // Filter data like {"subkey": [10]} $users = DB::table('users') ->whereRaw('JSON_EXTRACT(array_of_values, ?) >= ?', ['$."subkey"[0]']) ->get(); // Order by JSON value like {"value_name": "abc"} $users = DB::table('users') ->orderByRaw('JSON_EXTRACT(field_name, ?) ASC', ['$."value_name"']) ->get(); ```
References
Add additional online resources to your trick
×
Name
URL
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline