Commit 3df410e4 by Евгений

Улучшение #19453

Первоначальная загрузка всех РК аккаунтов.
1 parent 6010941e
...@@ -12,6 +12,7 @@ class Campaigns extends Model ...@@ -12,6 +12,7 @@ class Campaigns extends Model
protected $fillable = [ protected $fillable = [
'external_id', 'external_id',
'Name', 'Name',
'token',
'TimeTargeting', 'TimeTargeting',
'NegativeKeywords', 'NegativeKeywords',
'BlockedIps', 'BlockedIps',
......
...@@ -27,7 +27,8 @@ class CheckCampaignsChange extends DirectRequest { ...@@ -27,7 +27,8 @@ class CheckCampaignsChange extends DirectRequest {
'external_id' => $campaign['CampaignId'] 'external_id' => $campaign['CampaignId']
], ],
[ [
'updated' => $campaign['ChangesIn'] 'updated' => $campaign['ChangesIn'],
'token' => $this->getToken()->id
]); ]);
} }
} }
......
...@@ -19,6 +19,7 @@ class GetCampaigns extends DirectRequest{ ...@@ -19,6 +19,7 @@ class GetCampaigns extends DirectRequest{
foreach ($response['result']['Campaigns'] as $campaign){ foreach ($response['result']['Campaigns'] as $campaign){
$data[] = [ $data[] = [
'external_id' => $campaign['Id'], 'external_id' => $campaign['Id'],
'token' => $this->getToken()->id,
'Name' => $campaign['Name'], 'Name' => $campaign['Name'],
'TimeTargeting' => json_encode($campaign['TimeTargeting']), 'TimeTargeting' => json_encode($campaign['TimeTargeting']),
'NegativeKeywords' => !empty($campaign['NegativeKeywords']['Items']) ?implode("\n", $campaign['NegativeKeywords']['Items']):'', 'NegativeKeywords' => !empty($campaign['NegativeKeywords']['Items']) ?implode("\n", $campaign['NegativeKeywords']['Items']):'',
...@@ -39,6 +40,7 @@ class GetCampaigns extends DirectRequest{ ...@@ -39,6 +40,7 @@ class GetCampaigns extends DirectRequest{
Campaigns::upsert($data, [ Campaigns::upsert($data, [
'external_id' 'external_id'
],[ ],[
'token',
'Name', 'Name',
'TimeTargeting', 'TimeTargeting',
'NegativeKeywords', 'NegativeKeywords',
......
...@@ -15,6 +15,7 @@ class CreateCampaignsTable extends Migration ...@@ -15,6 +15,7 @@ class CreateCampaignsTable extends Migration
{ {
Schema::create('campaigns', function (Blueprint $table) { Schema::create('campaigns', function (Blueprint $table) {
$table->id(); $table->id();
$table->bigInteger('token');
$table->bigInteger('external_id')->unique(); $table->bigInteger('external_id')->unique();
$table->string('Name', 255)->nullable(); $table->string('Name', 255)->nullable();
$table->json('TimeTargeting')->nullable(); $table->json('TimeTargeting')->nullable();
...@@ -36,6 +37,8 @@ class CreateCampaignsTable extends Migration ...@@ -36,6 +37,8 @@ class CreateCampaignsTable extends Migration
\App\Service\Requests\Direct\CheckCampaignsChange::STAT, \App\Service\Requests\Direct\CheckCampaignsChange::STAT,
])->nullable(); ])->nullable();
$table->timestamps(); $table->timestamps();
$table->foreign('token')->references('id')->on('tokens');
}); });
} }
...@@ -46,6 +49,9 @@ class CreateCampaignsTable extends Migration ...@@ -46,6 +49,9 @@ class CreateCampaignsTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::table('campaigns', function (Blueprint $table) {
$table->dropForeign('campaigns_token_foreign');
});
Schema::dropIfExists('campaigns'); Schema::dropIfExists('campaigns');
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!