Commit d001fdbc by Vladislav

#19459 Вывод для основного аккаунта списка его РК из кеша

1 parent 0f2d6b16
...@@ -40,8 +40,8 @@ class TokensController extends Controller ...@@ -40,8 +40,8 @@ class TokensController extends Controller
'token' => $token->token, 'token' => $token->token,
'type' => $token->type, 'type' => $token->type,
'campaigns' => ( 'campaigns' => (
$token->type==Tokens::MAIN $token->type === Tokens::MAIN
? $token->campaigns ? $token->campaignsForManaged
: null : null
), ),
'cities' => ($token->type==Tokens::GOAL?[]:null), 'cities' => ($token->type==Tokens::GOAL?[]:null),
......
...@@ -28,8 +28,18 @@ class Campaigns extends Model ...@@ -28,8 +28,18 @@ class Campaigns extends Model
'updated' 'updated'
]; ];
protected $casts = [
'manage' => 'boolean',
'enabled' => 'boolean',
];
public function scopeForUpdated($query) public function scopeForUpdated($query)
{ {
$query->whereNotNull('updated'); $query->whereNotNull('updated');
} }
public function scopeForManaged($query)
{
$query->where('manage', true);
}
} }
...@@ -32,4 +32,9 @@ class Tokens extends Model ...@@ -32,4 +32,9 @@ class Tokens extends Model
{ {
return $this->hasMany(Campaigns::class, 'token', 'id')->orderBy('updated_at', 'DESC'); return $this->hasMany(Campaigns::class, 'token', 'id')->orderBy('updated_at', 'DESC');
} }
public function campaignsForManaged()
{
return $this->campaigns()->forManaged();
}
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
{{ campaign.name }} {{ campaign.name }}
</td> </td>
<td class="border-t py-3"> <td class="border-t py-3">
<input :id="'campaign-enabled-' + campaign.id" type="checkbox"> <input :id="'campaign-enabled-' + campaign.id" :checked="campaign.enabled" type="checkbox">
<label :for="'campaign-enabled-' + campaign.id">Enabled</label> <label :for="'campaign-enabled-' + campaign.id">Enabled</label>
<button class="text-red-600 hover:underline" <button class="text-red-600 hover:underline"
tabindex="-1" tabindex="-1"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!