# JSON Unicode Cast Type
12.3 Eloquent Attributes 新增 json:unicode cast type,允許 JSON encoding JSON_UNESCAPED_UNICODE
<?php
protected $casts = [
'data' => 'json:unicode',
];
# Add "Storage Linked" Check to the about Command
12.3,Artisan about command 新增 Storage section,會根據 config 顯示 filesystems link 狀態
<?php
// config/filesystem.php
return [
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => storage_path('app/images'),
],
];
$ php artisan about
Storage
public/images ................................................... NOT LINKED
public/storage .................................................. LINKED
# Native JSON and JSONB Column Types in SQLite Schema
- SQLite 自 3.38.0 起內建支援 JSON,而早期版本需要安裝 extension 才能使用。
- 自 3.45 起也支援 JSONB 型別(更有效率的 JSON 格式)。
- Laravel 12 支援 SQLite 3.26.0 & 更新版本,所以 Laravel 不能假設一定有 JSON/JSONB 功能。
- Query\Grammars\SQLiteGrammar:支援 JSON 查詢函數,而 Schema\Grammars\SQLiteGrammar:不支援 JSON 欄位結構定義。
- 綜上所述,12.3 加入一種方式,讓開發者可以透過資料庫設定檔,啟用 SQLite 原生 JSON/JSONB 功能,當 SQLite 是舊版本時,開發者可以默認不啟用,而當 SQLite 是新版本時,開發者可以選擇啟用
- 若啟用 JSON 時,Schema definition 也會支援 JSON,前提時 SQLite 版本至少要 3.38
<?php
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
...,
'use_native_json' => true,
'use_native_jsonb' => true,
],
# Support for PostgreSQL "unique nulls not distinct"
12.3 新增 nullsNotDistinct() method
一般 PostgreSQL 預設會把 NULL 當作彼此不相等,所以可以有多個 NULL 通過 unique 限制,可透過此 method 建立 NULL 不相等的 unique index
<?php
Schema::create('users', function (Blueprint $table) {
$table->string('email')->nullable();
// 建立 unique 索引,但 NULL 被視為 "相同"
$table->unique('email')->nullsNotDistinct();
});