【发布时间】:2019-04-24 15:07:15
【问题描述】:
我想将数据插入到我在 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”、...
【问题讨论】:
-
您想手动存储数据还是用户输入?
-
我正在点击 google ads api 及其返回给我的数据。我不使用表单或用户输入。只想存储来自该请求的数据。当我在公共方案(默认方式)时它正在工作,但现在我想存储在不同的模式中。
标签: php database laravel eloquent migration