是否可以在 Laravel 中一段时间后触发事件或侦听器,我的想法是在一分钟后设置一个侦听器来发送邮件,在用户注册后,cron 不是这种情况的解决方案。
你好我想尝试按月分组记录和订单总和价格
我试过这样的事
$order = Order::select(DB::raw('sum(price) as sums'))->groupBy(function($date) {
return Carbon::parse($date->created_at)->format('Y-m');
});
Run Code Online (Sandbox Code Playgroud)
但没有运气,我想获得我以后可以在数据表中实现的集合?
我在 Postgres 和 SQLite 中进行了迁移,并且面临 SQLite 数据库的问题。相同的迁移适用于 2 个不同的数据库。Postgres 迁移可以,但 SQlite 不行。我添加了用于更改表和添加新字段的迁移。
public function up()
{
Schema::table('retailer_products_photo_fix', function ($table) {
$table->integer('currency_id')->unsigned();
$table
->foreign('currency_id')
->references('id')
->on('currency')
->onUpdate('cascade')
->onDelete('cascade')
;
$table->dropColumn('currency');
});
}
Run Code Online (Sandbox Code Playgroud)
但抛出了以下错误:
General error: 1 Cannot add a NOT NULL column with default value NULL
Run Code Online (Sandbox Code Playgroud)
当我尝试添加 nullable() 字段时,未创建字段,并且当我添加默认值 0 或 1 时,我收到约束错误,因为在相关表中我有第 1 行和第 2 行。如何解决这个问题?