【发布时间】:2019-05-17 05:49:48
【问题描述】:
我正在使用 Laravel 队列功能将数据自动插入到数据库表中。如果表中没有记录,数据将自动保存。我的第一步是能够将数据插入表中,然后只进行验证。但是,我的数据似乎无法插入数据库。
我的队列功能
public function save_sale_price_on_the_fly($job, $data)
{
$selling_price = array_get($data, 'price');
$item_id = array_get($data, 'item_id');
$payee_id = array_get($data, 'payee_id');
DB::table('customer_products')
->where('product_id', '=', $item_id)
->where('customer_id', '=', $payee_id)
->where('different_price', '=', $selling_price)
->first();
}
我的模特
static::saved(function($model)
{
if (!$model->item_id && $model->payee_id && $model->price) {
Queue::push('InvoiceQueue@save_sale_price_on_the_fly', $model->toArray());
}
});
商品、收款人和价格从另一个表返回。我正在尝试将这 3 个值传递到我的 customer_products 表中。
【问题讨论】:
标签: php database laravel laravel-4