Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 054d90ff
authored
Aug 08, 2022
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#23510 Тестирование основного и целевого аккаунта
1 parent
a70c06c9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
0 deletions
app/Http/Controllers/TokensController.php
database/migrations/2022_08_08_110635_change_tokens_column_token.php
resources/js/Pages/Tokens/Edit.vue
routes/web.php
app/Http/Controllers/TokensController.php
View file @
054d90f
...
@@ -44,6 +44,84 @@ class TokensController extends Controller
...
@@ -44,6 +44,84 @@ class TokensController extends Controller
]);
]);
}
}
function
goalCopy
(
Tokens
$token
)
{
if
(
$token
->
type
!==
$token
::
MAIN
)
{
abort
(
404
);
}
$tokenGoal
=
Tokens
::
where
(
'type'
,
$token
::
GOAL
)
->
where
(
'token'
,
$token
->
token
)
->
first
();
if
(
$tokenGoal
)
{
return
Redirect
::
route
(
'token.edit'
,
$tokenGoal
->
getKey
());
}
$tokenGoal
=
$token
->
replicate
();
$tokenGoal
->
type
=
$token
::
GOAL
;
$tokenGoal
->
save
();
return
Redirect
::
route
(
'token.edit'
,
$tokenGoal
->
getKey
())
->
with
(
'success'
,
'Token added.'
);
$variables
=
Variable
::
all
();
$lists
=
[];
return
Inertia
::
render
(
'Tokens/Edit'
,
[
'token'
=>
[
'id'
=>
$token
->
getKey
(),
'login'
=>
$token
->
login
,
'api'
=>
$token
->
api
,
'token'
=>
$token
->
token
,
'type'
=>
$token
->
type
,
'main'
=>
$token
->
isMain
(),
'limit_to_run'
=>
$token
->
limit_to_run
,
'allow_retargeting_load'
=>
$token
->
allow_retargeting_load
,
'errors_count'
=>
$token
->
errors_count
,
'campaigns'
=>
(
$token
->
isMain
()
?
$token
->
campaignsForManaged
:
[]
),
'cities'
=>
(
!
$token
->
isMain
()
?
$token
->
load
(
'cities.dictionaryCampaigns'
)
->
cities
->
transform
(
function
(
$city
)
use
(
$variables
,
&
$lists
)
{
$city
->
dictionaryCampaigns
->
transform
(
function
(
$dictionaryCampaign
)
use
(
$variables
,
&
$lists
)
{
if
(
!
isset
(
$lists
[
$dictionaryCampaign
->
getKey
()]))
{
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$dictionaryCampaign
->
getKey
(),
$variables
);
$lists
[
$dictionaryCampaign
->
getKey
()]
=
$list
;
}
else
{
$list
=
$lists
[
$dictionaryCampaign
->
getKey
()];
}
$dictionaryCampaign
->
name
=
StrReplaceByVariables
::
getInstance
(
$dictionaryCampaign
->
name
,
$list
)
->
get
();
return
$dictionaryCampaign
;
});
return
$city
;
})
:
[]
),
],
'cities'
=>
(
!
$token
->
isMain
()
?
Dictionary
::
where
(
'type'
,
Dictionary
::
CITY
)
->
defaultOrderBy
()
->
get
()
:
[]
),
'campaigns'
=>
$token
->
campaigns
,
'main_token_campaigns'
=>
(
$mainToken
?
$mainToken
->
campaignsForManaged
:
[]
),
'types'
=>
$mainToken
&&
!
$token
->
type
===
Tokens
::
GOAL
?
[
Tokens
::
GOAL
=>
'Целевой аккаунт'
]
:
[
Tokens
::
MAIN
=>
'Основной аккаунт'
,
Tokens
::
GOAL
=>
'Целевой аккаунт'
],
]);
}
function
edit
(
Tokens
$token
)
function
edit
(
Tokens
$token
)
{
{
$token
->
loadCount
(
'errors'
);
$token
->
loadCount
(
'errors'
);
...
...
database/migrations/2022_08_08_110635_change_tokens_column_token.php
0 → 100644
View file @
054d90f
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
ChangeTokensColumnToken
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'tokens'
,
function
(
Blueprint
$table
)
{
$table
->
dropUnique
(
'tokens_token_unique'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'tokens'
,
function
(
Blueprint
$table
)
{
$table
->
unique
(
'token'
);
});
}
}
resources/js/Pages/Tokens/Edit.vue
View file @
054d90f
...
@@ -43,6 +43,14 @@
...
@@ -43,6 +43,14 @@
>
>
Delete Token
Delete Token
</button>
</button>
<inertia-link
v-if=
"form.type === 'main'"
class=
"hover:underline ml-28"
tabindex=
"-1"
type=
"button"
:href=
"route('token.goal.copy', token.id)"
>
Копировать целевой токен
</inertia-link>
<loading-button
:loading=
"form.processing"
class=
"btn-indigo ml-auto"
type=
"submit"
>
<loading-button
:loading=
"form.processing"
class=
"btn-indigo ml-auto"
type=
"submit"
>
Update Token
Update Token
</loading-button>
</loading-button>
...
...
routes/web.php
View file @
054d90f
...
@@ -164,6 +164,9 @@ Route::group(['middleware' => 'auth'], function () {
...
@@ -164,6 +164,9 @@ Route::group(['middleware' => 'auth'], function () {
Route
::
post
(
'tokens'
,
[
TokensController
::
class
,
'cronSyncUpdate'
])
Route
::
post
(
'tokens'
,
[
TokensController
::
class
,
'cronSyncUpdate'
])
->
name
(
'cron_sync_update'
);
->
name
(
'cron_sync_update'
);
Route
::
get
(
'token/goal/copy/{token}'
,
[
TokensController
::
class
,
'goalCopy'
])
->
name
(
'token.goal.copy'
);
Route
::
get
(
'token/edit/{token}'
,
[
TokensController
::
class
,
'edit'
])
Route
::
get
(
'token/edit/{token}'
,
[
TokensController
::
class
,
'edit'
])
->
name
(
'token.edit'
);
->
name
(
'token.edit'
);
Route
::
get
(
'token/errors/{token}'
,
[
TokensController
::
class
,
'errors'
])
Route
::
get
(
'token/errors/{token}'
,
[
TokensController
::
class
,
'errors'
])
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment