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 3ade173c
authored
May 17, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19461 Страница настройки целевых аккаунтов.
1 parent
93ef4562
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
81 deletions
app/Http/Controllers/TokensController.php
app/Models/Dictionary.php
app/Models/Pivots/TokenDictionaryPivot.php
app/Models/Tokens.php
database/migrations/2021_05_11_094828_create_dictionaries_table.php
database/migrations/2021_05_14_173925_create_token_dictionaries.php
resources/js/Pages/Tokens/CampaignsSettings.vue
resources/js/Pages/Tokens/Edit.vue
routes/web.php
app/Http/Controllers/TokensController.php
View file @
3ade173
...
@@ -83,7 +83,7 @@ class TokensController extends Controller
...
@@ -83,7 +83,7 @@ class TokensController extends Controller
return
Redirect
::
back
()
->
with
(
'success'
,
'Token updated.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Token updated.'
);
}
}
public
function
managedCampaign
(
Tokens
$token
,
$campaign_id
,
$managed
)
public
function
managedCampaign
(
Tokens
$token
,
$campaign_id
)
{
{
if
(
!
$token
->
isMain
())
{
if
(
!
$token
->
isMain
())
{
return
Redirect
::
back
();
return
Redirect
::
back
();
...
@@ -96,13 +96,13 @@ class TokensController extends Controller
...
@@ -96,13 +96,13 @@ class TokensController extends Controller
}
}
$campaign
->
update
([
$campaign
->
update
([
'manage'
=>
!!
request
(
'manage'
),
'manage'
=>
!!
request
(
'manage
d
'
),
]);
]);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign '
.
(
$
managed
?
'added'
:
'deleted'
)
.
'.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign '
.
(
$
campaign
->
manage
?
'added'
:
'deleted'
)
.
'.'
);
}
}
public
function
enabledCampaign
(
Tokens
$token
,
$campaign_id
,
$enabled
)
public
function
enabledCampaign
(
Tokens
$token
,
$campaign_id
)
{
{
if
(
!
$token
->
isMain
())
{
if
(
!
$token
->
isMain
())
{
return
Redirect
::
back
();
return
Redirect
::
back
();
...
@@ -118,7 +118,7 @@ class TokensController extends Controller
...
@@ -118,7 +118,7 @@ class TokensController extends Controller
'enabled'
=>
!!
request
(
'enabled'
),
'enabled'
=>
!!
request
(
'enabled'
),
]);
]);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign '
.
(
$enabled
?
'enabled'
:
'disabled'
)
.
'.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign '
.
(
$
campaign
->
enabled
?
'enabled'
:
'disabled'
)
.
'.'
);
}
}
public
function
destroy
(
Tokens
$token
)
public
function
destroy
(
Tokens
$token
)
...
@@ -153,7 +153,7 @@ class TokensController extends Controller
...
@@ -153,7 +153,7 @@ class TokensController extends Controller
return
Redirect
::
back
();
return
Redirect
::
back
();
}
}
$
token
->
cities
()
->
syncWithoutDetaching
(
$city
);
$
city
->
token
()
->
associate
(
$token
->
getKey
()
);
return
Redirect
::
route
(
'token.edit'
,
$token
->
getKey
())
->
with
(
'success'
,
'City added.'
);
return
Redirect
::
route
(
'token.edit'
,
$token
->
getKey
())
->
with
(
'success'
,
'City added.'
);
}
}
...
@@ -164,7 +164,13 @@ class TokensController extends Controller
...
@@ -164,7 +164,13 @@ class TokensController extends Controller
return
Redirect
::
back
();
return
Redirect
::
back
();
}
}
$token
->
cities
()
->
updateExistingPivot
(
$city
,
[
$city
=
$token
->
cities
()
->
find
(
$city
);
if
(
!
$city
)
{
return
Redirect
::
back
();
}
$city
->
update
([
'updated'
=>
!!
request
(
'updated'
),
'updated'
=>
!!
request
(
'updated'
),
]);
]);
...
@@ -190,7 +196,7 @@ class TokensController extends Controller
...
@@ -190,7 +196,7 @@ class TokensController extends Controller
return
Redirect
::
back
();
return
Redirect
::
back
();
}
}
$
token
->
cities
()
->
detach
(
$city
);
$
city
->
token
()
->
associate
(
null
);
return
Redirect
::
route
(
'token.edit'
,
$token
->
getKey
())
->
with
(
'success'
,
'City deleted.'
);
return
Redirect
::
route
(
'token.edit'
,
$token
->
getKey
())
->
with
(
'success'
,
'City deleted.'
);
}
}
...
...
app/Models/Dictionary.php
View file @
3ade173
...
@@ -8,6 +8,15 @@ class Dictionary extends Model
...
@@ -8,6 +8,15 @@ class Dictionary extends Model
{
{
CONST
CITY
=
'City'
;
CONST
CITY
=
'City'
;
protected
$casts
=
[
'update'
=>
'boolean'
,
];
public
function
token
()
{
return
$this
->
belongsTo
(
Tokens
::
class
,
'token_id'
);
}
public
function
scopeDefaultOrderBy
(
Builder
$query
)
public
function
scopeDefaultOrderBy
(
Builder
$query
)
{
{
return
$query
->
orderBy
(
'name'
);
return
$query
->
orderBy
(
'name'
);
...
...
app/Models/Pivots/TokenDictionaryPivot.php
deleted
100644 → 0
View file @
93ef456
<?php
namespace
App\Models\Pivots
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
class
TokenDictionaryPivot
extends
Pivot
{
protected
$casts
=
[
'token_id'
=>
'int'
,
'dictionary_id'
=>
'int'
,
'updated'
=>
'boolean'
,
];
}
app/Models/Tokens.php
View file @
3ade173
...
@@ -30,21 +30,20 @@ class Tokens extends Model
...
@@ -30,21 +30,20 @@ class Tokens extends Model
public
function
limits
()
public
function
limits
()
{
{
return
$this
->
hasMany
(
Limits
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
return
$this
->
hasMany
(
Limits
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
}
}
public
function
campaigns
()
public
function
campaigns
()
{
{
return
$this
->
hasMany
(
Campaigns
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
return
$this
->
hasMany
(
Campaigns
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
}
}
public
function
cities
()
public
function
cities
()
{
{
return
$this
->
belongsToMany
(
Dictionary
::
class
,
'token_dictionaries'
,
'token_id'
,
'dictionary_id'
)
return
$this
->
hasMany
(
Dictionary
::
class
,
'token_id'
,
'id'
)
->
using
(
TokenDictionaryPivot
::
class
)
->
orderBy
(
'updated_at'
,
'DESC'
);
->
withPivot
(
'updated'
)
->
withTimestamps
()
->
orderBy
(
'token_dictionaries.created_at'
,
'desc'
);
}
}
public
function
campaignsForManaged
()
public
function
campaignsForManaged
()
...
...
database/migrations/2021_05_11_094828_create_dictionaries_table.php
View file @
3ade173
...
@@ -19,7 +19,11 @@ class CreateDictionariesTable extends Migration
...
@@ -19,7 +19,11 @@ class CreateDictionariesTable extends Migration
$table
->
bigInteger
(
'parent_id'
)
->
nullable
();
$table
->
bigInteger
(
'parent_id'
)
->
nullable
();
$table
->
string
(
'name'
,
255
);
$table
->
string
(
'name'
,
255
);
$table
->
string
(
'type'
,
255
);
$table
->
string
(
'type'
,
255
);
$table
->
bigInteger
(
'token_id'
)
->
nullable
();
$table
->
boolean
(
'update'
)
->
default
(
1
);
$table
->
timestamps
();
$table
->
timestamps
();
$table
->
foreign
(
'token_id'
)
->
references
(
'id'
)
->
on
(
'tokens'
);
});
});
}
}
...
...
database/migrations/2021_05_14_173925_create_token_dictionaries.php
deleted
100644 → 0
View file @
93ef456
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateTokenDictionaries
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'token_dictionaries'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
bigInteger
(
'token_id'
);
$table
->
bigInteger
(
'dictionary_id'
);
$table
->
boolean
(
'updated'
)
->
default
(
1
);
$table
->
timestamps
();
$table
->
foreign
(
'token_id'
)
->
references
(
'id'
)
->
on
(
'tokens'
);
$table
->
foreign
(
'dictionary_id'
)
->
references
(
'id'
)
->
on
(
'dictionaries'
);
$table
->
unique
([
'token_id'
,
'dictionary_id'
]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'token_dictionaries'
);
}
}
resources/js/Pages/Tokens/CampaignsSettings.vue
View file @
3ade173
<
template
>
<
template
>
<div>
<div>
<h2
class=
"mt-12 font-bold text-2xl"
>
Campaigns
</h2>
<h2
class=
"mt-12 font-bold text-2xl"
>
Campaigns
</h2>
<div
class=
"mt-4 flex flex-wrap"
>
<form
v-if=
"campaigns.length"
@
submit
.
prevent=
"add(campaign_id)"
class=
"
flex flex-wrap"
>
<div
v-if=
"campaigns.length"
class=
"mt-4
flex flex-wrap"
>
<select-input
v-model=
"campaign_id"
<select-input
v-model=
"campaign_id"
:readonly=
"campaign_id"
:readonly=
"campaign_id"
class=
"pr-6"
class=
"pr-6"
...
@@ -11,14 +11,15 @@
...
@@ -11,14 +11,15 @@
{{
campaign
.
name
}}
{{
campaign
.
name
}}
</option>
</option>
</select-input>
</select-input>
<loading-
button
class=
"btn-indigo hover:underline pl-6"
<
button
class=
"btn-indigo hover:underline pl-6"
tabindex=
"-1"
tabindex=
"-1"
type=
"submit"
type=
"button"
@
click=
"add"
>
>
Add
Add
</loading-button>
</button>
</form>
</div>
</div>
<div
class=
"mt-4 flex flex-wrap"
>
<div
class=
"mt-4 flex flex-wrap"
>
</div>
</div>
<div
class=
"mt-6 bg-white rounded shadow overflow-x-auto"
>
<div
class=
"mt-6 bg-white rounded shadow overflow-x-auto"
>
...
@@ -81,14 +82,14 @@
...
@@ -81,14 +82,14 @@
},
},
methods
:
{
methods
:
{
add
(
campaign_id
)
{
add
()
{
if
(
!
campaign_id
)
{
if
(
!
this
.
campaign_id
)
{
return
;
return
;
}
}
this
.
$emit
(
'add'
,
campaign_id
)
this
.
$emit
(
'add'
,
this
.
campaign_id
)
},
},
enabled
(
campaign_id
)
{
enabled
(
campaign_id
,
enabled
)
{
this
.
$emit
(
'enabled'
,
campaign_id
)
this
.
$emit
(
'enabled'
,
campaign_id
,
enabled
)
},
},
delete
(
campaign_id
)
{
delete
(
campaign_id
)
{
this
.
$emit
(
'delete'
,
campaign_id
)
this
.
$emit
(
'delete'
,
campaign_id
)
...
...
resources/js/Pages/Tokens/Edit.vue
View file @
3ade173
...
@@ -127,12 +127,12 @@ export default {
...
@@ -127,12 +127,12 @@ export default {
},
},
campaignEnabled
(
campaign_id
,
enabled
)
{
campaignEnabled
(
campaign_id
,
enabled
)
{
this
.
$inertia
.
post
(
this
.
route
(
'token.campaign.enabled'
,
[
this
.
token
.
id
,
campaign_id
]),
{
this
.
$inertia
.
post
(
this
.
route
(
'token.campaign.enabled'
,
[
this
.
token
.
id
,
campaign_id
]),
{
updat
ed
:
enabled
?
1
:
0
,
enabl
ed
:
enabled
?
1
:
0
,
});
});
},
},
campaignManaged
(
campaign_id
,
managed
)
{
campaignManaged
(
campaign_id
,
managed
)
{
this
.
$inertia
.
post
(
this
.
route
(
'token.campaign.managed'
,
[
this
.
token
.
id
,
campaign_id
]),
{
this
.
$inertia
.
post
(
this
.
route
(
'token.campaign.managed'
,
[
this
.
token
.
id
,
campaign_id
]),
{
updat
ed
:
managed
?
1
:
0
,
manag
ed
:
managed
?
1
:
0
,
});
});
},
},
campaignDelete
(
campaign_id
)
{
campaignDelete
(
campaign_id
)
{
...
...
routes/web.php
View file @
3ade173
...
@@ -173,7 +173,7 @@ Route::delete('token/delete/{token}', [TokensController::class, 'destroy'])
...
@@ -173,7 +173,7 @@ Route::delete('token/delete/{token}', [TokensController::class, 'destroy'])
->
name
(
'token.destroy'
)
->
name
(
'token.destroy'
)
->
middleware
(
'auth'
);
->
middleware
(
'auth'
);
Route
::
post
(
'token/campaigns/managed/{token}/{campaign_id}
/{managed}
'
,
[
TokensController
::
class
,
'managedCampaign'
])
Route
::
post
(
'token/campaigns/managed/{token}/{campaign_id}'
,
[
TokensController
::
class
,
'managedCampaign'
])
->
name
(
'token.campaign.managed'
)
->
name
(
'token.campaign.managed'
)
->
middleware
(
'auth'
);
->
middleware
(
'auth'
);
Route
::
post
(
'token/campaigns/enabled/{token}/{campaign_id}'
,
[
TokensController
::
class
,
'enabledCampaign'
])
Route
::
post
(
'token/campaigns/enabled/{token}/{campaign_id}'
,
[
TokensController
::
class
,
'enabledCampaign'
])
...
...
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