GoalAdvertisement.php
7.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
namespace App\Models\Pivots;
use App\Models\Advertisement;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\Pivots\GoalAdvertisement
*
* @property int $id
* @property int|null $external_id
* @property int|null $goal_v_card_external_id
* @property int|null $dictionary_campaign_external_id
* @property int|null $goal_ad_group_external_id
* @property int $dictionary_campaign_id
* @property int|null $goal_v_card_id
* @property int $goal_ad_group_id
* @property int $advertisement_id
* @property \Illuminate\Support\Carbon|null $external_upload_at
* @property \Illuminate\Support\Carbon|null $external_updated_at
* @property \Illuminate\Support\Carbon|null $updated_need
* @property \Illuminate\Support\Carbon|null $archived_need
* @property \Illuminate\Support\Carbon|null $reserve_archive_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read Advertisement $advertisement
* @method static Builder|GoalAdvertisement forExternal()
* @method static Builder|GoalAdvertisement forNotExternal()
* @method static Builder|GoalAdvertisement forNotReserveCreate()
* @method static Builder|GoalAdvertisement forNotReserveUpdate()
* @method static Builder|GoalAdvertisement forNotReserveArchive()
* @method static Builder|GoalAdvertisement needUpdated()
* @method static Builder|GoalAdvertisement needArchived()
* @method static Builder|GoalAdvertisement notNeedArchived()
* @method static Builder|GoalAdvertisement newModelQuery()
* @method static Builder|GoalAdvertisement newQuery()
* @method static Builder|GoalAdvertisement query()
* @method static Builder|GoalAdvertisement whereCreatedAt($value)
* @method static Builder|GoalAdvertisement whereDictionaryCampaignExternalId($value)
* @method static Builder|GoalAdvertisement whereDictionaryCampaignId($value)
* @method static Builder|GoalAdvertisement whereExternalId($value)
* @method static Builder|GoalAdvertisement whereExternalUpdatedAt($value)
* @method static Builder|GoalAdvertisement whereExternalUploadAt($value)
* @method static Builder|GoalAdvertisement whereGoalAdGroupExternalId($value)
* @method static Builder|GoalAdvertisement whereGoalAdGroupId($value)
* @method static Builder|GoalAdvertisement whereId($value)
* @method static Builder|GoalAdvertisement whereAdvertisementId($value)
* @method static Builder|GoalAdvertisement whereUpdatedAt($value)
* @method static Builder|GoalAdvertisement whereUpdatedNeed($value)
* @mixin \Eloquent
*/
class GoalAdvertisement extends Pivot
{
use SoftDeletes;
protected $table = 'goal_advertisements';
protected $fillable = [
'external_id',
'goal_v_card_external_id',
'goal_sitelink_external_id',
'goal_ad_group_external_id',
'dictionary_campaign_external_id',
'goal_v_card_id',
'goal_sitelink_id',
'goal_ad_group_id',
'dictionary_campaign_id',
'advertisement_id',
'external_upload_at',
'external_updated_at',
'updated_need',
'reserve_create_at',
'reserve_update_at',
'archive_at',
'archived_need',
'reserve_archive_at',
'deleted_need',
'reserve_delete_at',
];
protected $casts = [
'external_upload_at' => 'datetime',
'external_updated_at' => 'datetime',
'updated_need' => 'datetime',
'reserve_create_at' => 'datetime',
'reserve_update_at' => 'datetime',
'archive_at' => 'datetime',
'archived_need' => 'datetime',
'reserve_archive_at' => 'datetime',
'deleted_need' => 'datetime',
'reserve_delete_at' => 'datetime',
];
public $incrementing = true;
static public function getWithPivot()
{
return [
'id',
'external_id',
'goal_v_card_external_id',
'goal_sitelink_external_id',
'goal_ad_group_external_id',
'dictionary_campaign_external_id',
'goal_v_card_id',
'goal_sitelink_id',
'goal_ad_group_id',
'dictionary_campaign_id',
'advertisement_id',
'external_upload_at',
'external_updated_at',
'updated_need',
'reserve_create_at',
'reserve_update_at',
'deleted_need',
'reserve_delete_at',
'archived_need',
'reserve_archive_at',
'archive_at',
];
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForExternal($query)
{
return $query->whereNotNull('external_id');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForNotExternal($query)
{
return $query->whereNull('external_id');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForNotReserveCreate($query)
{
return $query->whereNull('reserve_create_at');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForNotReserveUpdate($query)
{
return $query->whereNull('reserve_update_at');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeNeedUpdated($query)
{
return $query->whereNotNull('updated_need');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForArchived($query)
{
return $query->whereNotNull('archive_at');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForNotArchived($query)
{
return $query->whereNull('archive_at');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeNeedArchived($query)
{
return $query->whereNotNull('archived_need');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeNotNeedArchived($query)
{
return $query->whereNull('archived_need');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForNotReserveArchive($query)
{
return $query->whereNull('reserve_archive_at');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeNeedDeleted($query)
{
return $query->whereNotNull('deleted_need');
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeForNotReserveDelete($query)
{
return $query->whereNull('reserve_delete_at');
}
public function advertisement()
{
return $this->belongsTo(Advertisement::class, 'advertisement_id');
}
public function dictionaryCampaign()
{
return $this->belongsTo(DictionaryCampaign::class, 'dictionary_campaign_id');
}
public function goalVCard()
{
return $this->belongsTo(GoalVCard::class, 'goal_v_card_id');
}
public function goalAdExtensions()
{
return $this->belongsToMany(GoalAdExtension::class, GoalAdvertisementGoalAdExtension::getModel()->getTable(), 'goal_advertisement_id', 'goal_ad_extension_id')
->using(GoalAdvertisementGoalAdExtension::class)
->withPivot(GoalAdvertisementGoalAdExtension::getWithPivot())
->withTimestamps();
}
public function goalAdExtensionsForNotExternal()
{
return $this->goalAdExtensions()->forNotExternal();
}
}