我想在laravel迁移中创建的架构中插入数据,但找不到方法。
有人可以指导吗?
public function up()
{
DB::statement('CREATE SCHEMA IF NOT EXISTS reports');
Schema::create('reports.campaign_reports', function (Blueprint $table)
{
$table->bigIncrements('id');
$table->string('campaign')->nullable();
$table->string('currency')->nullable();
});
}
这是我的模型:
class CampaignReport extends Model
{
// protected $connection = 'schema.reports';
protected $table = 'campaign_reports';
protected $fillable = [
'campaign',
'currency'
];
}
这就是我节省的方式:
CampaignReport::create((array) $dataObject);
我收到此错误:
SQLSTATE [42P01]:未定义表:7错误:关系“ campaign_reports”不存在第1行:插入“ campaign_reports”(“ campaign”,“ currency”,...