new CartItem (['amount' => $amount])
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CartItem extends Model
{
protected $fillable = ['amount'];
public $timestamps = false;
public function user()
{
return $this->belongsTo(User::class);
}
public function productSku()
{
return $this->belongsTo(ProductSku::class);
}
}
use App\Models\CartItem;
$cart = new CartItem ([‘amount’ => $amount]);// 为什么可以这样用,直接 new 一下,amount 的值就传进去了?
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: