0
我想構建一張購物卡,原因是所有的購物車都在使用會話,並且我希望將數據保存到帶有json的數據庫中。遷移購物車laravel
現在是正確的方式開始。
遷移
public function up()
{
Schema::create('shopping_carts', function (Blueprint $table) {
$table->increments('id');
$table->json('soppingCart');
$table->timestamps();
});
}
模型
class ShoppingCart extends Model
{
protected $fillable = ['shoppingCart'];
protected $casts =['shoppingCart' =>'json'];
}
我是否錯過了什麼?
謝謝,但一般來說是正確的開始? –