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 12de07a9
authored
May 18, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19462 Добавление в настройки городов переменных.v
1 parent
a2df7886
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
183 additions
and
105 deletions
app/Http/Controllers/CampaignVariablesController.php
app/Http/Controllers/TokensController.php
app/Models/Dictionary.php
app/Models/Pivots/DictionaryCampaign.php
app/Models/Tokens.php
app/Models/Variable.php
database/migrations/2021_05_17_101448_create_campaign_variables_table.php
resources/js/Pages/CampaignVariables/Edit.vue
resources/js/Pages/Tokens/CitySettings.vue
routes/web.php
app/Http/Controllers/CampaignVariablesController.php
View file @
12de07a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Models\Campaigns
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Models\Variable
;
use
App\Models\Variable
;
use
Illuminate\Support\Facades\Redirect
;
use
Illuminate\Support\Facades\Redirect
;
...
@@ -13,7 +14,8 @@ class CampaignVariablesController extends Controller
...
@@ -13,7 +14,8 @@ class CampaignVariablesController extends Controller
protected
$rule_variable
=
'required|exists:variables,id'
;
protected
$rule_variable
=
'required|exists:variables,id'
;
protected
$rule_variable_name
=
'required|alpha|regex:/[a-zA-z]/'
;
protected
$rule_variable_name
=
'required|alpha|regex:/[a-zA-z]/'
;
protected
$rule_value
=
'required'
;
protected
$rule_default_value
=
'required'
;
protected
$rule_value
=
''
;
function
__invoke
(
Tokens
$token
,
$campaign_id
)
function
__invoke
(
Tokens
$token
,
$campaign_id
)
{
{
...
@@ -21,7 +23,7 @@ class CampaignVariablesController extends Controller
...
@@ -21,7 +23,7 @@ class CampaignVariablesController extends Controller
return
Redirect
::
back
();
return
Redirect
::
back
();
}
}
$campaign
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
get
()
->
first
()
->
campaignsFor
Enabl
ed
()
->
with
(
'variables'
)
->
find
(
$campaign_id
);
$campaign
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
get
()
->
first
()
->
campaignsFor
Manag
ed
()
->
with
(
'variables'
)
->
find
(
$campaign_id
);
if
(
!
$campaign
)
{
if
(
!
$campaign
)
{
return
Redirect
::
back
();
return
Redirect
::
back
();
...
@@ -29,88 +31,113 @@ class CampaignVariablesController extends Controller
...
@@ -29,88 +31,113 @@ class CampaignVariablesController extends Controller
switch
(
request
()
->
method
())
{
switch
(
request
()
->
method
())
{
case
'GET'
:
case
'GET'
:
$variables
=
Variable
::
defaultOrderBy
()
->
get
()
->
transform
(
function
(
Variable
$variable
)
use
(
$campaign
)
{
$variable
->
campaign
=
$variable
->
campaigns
()
->
where
(
'campaign_id'
,
$campaign
->
getKey
())
->
first
();
return
$variable
;
});
return
Inertia
::
render
(
'CampaignVariables/Edit'
,
[
return
Inertia
::
render
(
'CampaignVariables/Edit'
,
[
'variables'
=>
Variable
::
defaultOrderBy
()
->
get
()
,
'variables'
=>
$variables
,
'token'
=>
$token
,
'token'
=>
$token
,
'campaign'
=>
$campaign
,
'campaign'
=>
$campaign
,
]);
]);
break
;
case
'POST'
:
case
'POST'
:
if
(
request
(
'variable'
)
===
'add'
)
{
if
(
request
(
'variable'
)
===
'add'
)
{
Request
::
validate
([
Request
::
validate
([
'name'
=>
$this
->
rule_variable_name
,
'name'
=>
$this
->
rule_variable_name
,
'
value'
=>
$this
->
rule
_value
,
'
default_value'
=>
$this
->
rule_default
_value
,
]);
]);
$variable_new
=
Variable
::
create
([
$variable_new
=
Variable
::
create
(
Request
::
only
([
'name'
=>
request
(
'name'
),
'name'
,
]);
'default_value'
,
]));
$variable_id
=
$variable_new
->
getKey
();
$variable_id
=
$variable_new
->
getKey
();
$value
=
request
(
'value'
);
$value
=
request
(
'value'
);
}
else
{
}
else
{
Request
::
validate
([
Request
::
validate
([
'variable'
=>
$this
->
rule_variable
,
'variable'
=>
$this
->
rule_variable
,
'value'
=>
$this
->
rule_value
,
]);
]);
$variable_id
=
request
(
'variable'
);
$variable_id
=
request
(
'variable'
);
$value
=
request
(
'value'
);
$value
=
request
(
'value'
);
}
}
$campaign
->
variables
()
->
syncWithoutDetaching
([
$this
->
putCampaignVariableValue
(
$campaign
,
$variable_id
,
$value
);
$variable_id
=>
[
'value'
=>
$value
,
],
]);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable added.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable added.'
);
break
;
break
;
case
'PUT'
:
case
'PUT'
:
$campaign_variable
=
$campaign
->
variables
()
->
find
(
request
(
'id'
));
Request
::
validate
([
'value'
=>
$this
->
rule_value
if
(
!
$campaign_variable
)
{
return
Redirect
::
back
();
}
$campaign_variable
->
update
([
Request
::
validate
([
'name'
=>
$this
->
rule_variable_name
])
]);
]);
return
Redirect
::
back
()
->
with
(
'success'
,
'Variable name updated.'
);
$this
->
putCampaignVariableValue
(
$campaign
,
request
(
'id'
),
request
(
'value'
));
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable updated.'
);
break
;
break
;
case
'PATCH'
:
case
'PATCH'
:
$
campaign_variable
=
$campaign
->
variables
()
->
find
(
request
(
'id'
));
$
variable
=
Variable
::
find
(
request
(
'id'
));
if
(
!
$
campaign_
variable
)
{
if
(
!
$variable
)
{
return
Redirect
::
back
();
return
Redirect
::
back
();
}
}
if
(
request
()
->
validate
([
'value'
=>
$this
->
rule_value
]))
{
$variable
->
update
(
Request
::
validate
([
$campaign_variable
->
update
(
request
()
->
only
(
'value'
));
'name'
=>
$this
->
rule_variable_name
,
}
'default_value'
=>
$this
->
rule_default_value
,
]));
return
Redirect
::
back
()
->
with
(
'success'
,
'
Campaign variabl
e updated.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'
Variable nam
e updated.'
);
break
;
break
;
case
'DELETE'
:
}
$campaign_variable
=
$campaign
->
vars
()
->
find
(
request
(
'id'
));
return
Redirect
::
back
();
}
if
(
!
$campaign_variable
)
{
public
function
destroy
(
Tokens
$token
,
$campaign_id
,
$variable_id
)
return
Redirect
::
back
();
{
}
if
(
$token
->
isMain
())
{
return
Redirect
::
back
();
}
$campaign_variable
->
delete
(
);
$variable
=
Variable
::
find
(
$variable_id
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable deleted.'
);
if
(
!
$variable
)
{
break
;
return
Redirect
::
back
()
;
}
}
;
return
Redirect
::
back
();
$variable
->
delete
();
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable deleted.'
);
}
}
/**
* @param Campaigns $campaign
* @param integer $variable_id
* @param string|null $value
*/
private
function
putCampaignVariableValue
(
Campaigns
$campaign
,
$variable_id
,
$value
=
null
)
{
if
(
is_null
(
$value
))
{
$campaign
->
variables
()
->
detach
(
$variable_id
);
}
else
{
$campaign
->
variables
()
->
syncWithoutDetaching
([
$variable_id
=>
[
'value'
=>
$value
,
],
]);
}
}
}
}
app/Http/Controllers/TokensController.php
View file @
12de07a
...
@@ -157,7 +157,7 @@ class TokensController extends Controller
...
@@ -157,7 +157,7 @@ class TokensController extends Controller
return
Redirect
::
back
();
return
Redirect
::
back
();
}
}
$token_main
=
Tokens
::
with
(
'campaignsFor
Enabl
ed'
)
->
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
$token_main
=
Tokens
::
with
(
'campaignsFor
Manag
ed'
)
->
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
if
(
!
$token_main
)
{
if
(
!
$token_main
)
{
return
Redirect
::
back
();
return
Redirect
::
back
();
...
@@ -168,9 +168,9 @@ class TokensController extends Controller
...
@@ -168,9 +168,9 @@ class TokensController extends Controller
$token
->
cities
()
->
save
(
$city
);
$token
->
cities
()
->
save
(
$city
);
if
(
$token_main
->
campaignsFor
Enabl
ed
->
count
())
{
if
(
$token_main
->
campaignsFor
Manag
ed
->
count
())
{
$city
->
campaigns
()
->
syncWithoutDetaching
(
$city
->
campaigns
()
->
syncWithoutDetaching
(
$token_main
->
campaignsFor
Enabled
->
keyBy
(
$token_main
->
campaignsForEnabl
ed
->
first
()
->
getKeyName
())
->
transform
(
function
(
Campaigns
$campaign
)
{
$token_main
->
campaignsFor
Managed
->
keyBy
(
$token_main
->
campaignsForManag
ed
->
first
()
->
getKeyName
())
->
transform
(
function
(
Campaigns
$campaign
)
{
return
DictionaryCampaign
::
copyPropertyInCampaign
(
$campaign
);
return
DictionaryCampaign
::
copyPropertyInCampaign
(
$campaign
);
})
->
all
()
})
->
all
()
);
);
...
...
app/Models/Dictionary.php
View file @
12de07a
...
@@ -17,6 +17,11 @@ class Dictionary extends Model
...
@@ -17,6 +17,11 @@ class Dictionary extends Model
'update'
=>
'boolean'
,
'update'
=>
'boolean'
,
];
];
public
function
scopeDefaultOrderBy
(
Builder
$query
)
{
return
$query
->
orderBy
(
'name'
);
}
public
function
token
()
public
function
token
()
{
{
return
$this
->
belongsTo
(
Tokens
::
class
,
'token_id'
);
return
$this
->
belongsTo
(
Tokens
::
class
,
'token_id'
);
...
@@ -30,9 +35,4 @@ class Dictionary extends Model
...
@@ -30,9 +35,4 @@ class Dictionary extends Model
->
withTimestamps
();
->
withTimestamps
();
}
}
public
function
scopeDefaultOrderBy
(
Builder
$query
)
{
return
$query
->
orderBy
(
'name'
);
}
}
}
app/Models/Pivots/DictionaryCampaign.php
View file @
12de07a
...
@@ -18,6 +18,12 @@ class DictionaryCampaign extends Pivot
...
@@ -18,6 +18,12 @@ class DictionaryCampaign extends Pivot
'updated'
,
'updated'
,
];
];
protected
$cast
=
[
'campaign_id'
=>
'int'
,
'dictionary_id'
=>
'int'
,
'updated'
=>
'boolean'
,
];
static
public
function
getWithPivot
()
static
public
function
getWithPivot
()
{
{
return
[
return
[
...
@@ -39,12 +45,6 @@ class DictionaryCampaign extends Pivot
...
@@ -39,12 +45,6 @@ class DictionaryCampaign extends Pivot
})
->
flatMap
(
fn
(
$val
)
=>
$val
)
->
all
();
})
->
flatMap
(
fn
(
$val
)
=>
$val
)
->
all
();
}
}
protected
$cast
=
[
'campaign_id'
=>
'int'
,
'dictionary_id'
=>
'int'
,
'updated'
=>
'boolean'
,
];
public
function
dictionary
()
public
function
dictionary
()
{
{
return
$this
->
belongsTo
(
Dictionary
::
class
,
'dictionary_id'
);
return
$this
->
belongsTo
(
Dictionary
::
class
,
'dictionary_id'
);
...
...
app/Models/Tokens.php
View file @
12de07a
...
@@ -39,11 +39,6 @@ class Tokens extends Model
...
@@ -39,11 +39,6 @@ class Tokens extends Model
->
orderBy
(
'updated_at'
,
'DESC'
);
->
orderBy
(
'updated_at'
,
'DESC'
);
}
}
public
function
campaignsForEnabled
()
{
return
$this
->
campaigns
()
->
forEnabled
();
}
public
function
cities
()
public
function
cities
()
{
{
return
$this
->
hasMany
(
Dictionary
::
class
,
'token_id'
,
'id'
)
return
$this
->
hasMany
(
Dictionary
::
class
,
'token_id'
,
'id'
)
...
...
app/Models/Variable.php
View file @
12de07a
...
@@ -7,6 +7,10 @@ use Illuminate\Database\Eloquent\Builder;
...
@@ -7,6 +7,10 @@ use Illuminate\Database\Eloquent\Builder;
class
Variable
extends
Model
class
Variable
extends
Model
{
{
protected
$fillable
=
[
'name'
,
'default_value'
,
];
public
function
scopeDefaultOrderBy
(
Builder
$query
)
public
function
scopeDefaultOrderBy
(
Builder
$query
)
{
{
...
...
database/migrations/2021_05_17_101448_create_campaign_variables_table.php
View file @
12de07a
...
@@ -21,8 +21,10 @@ class CreateCampaignVariablesTable extends Migration
...
@@ -21,8 +21,10 @@ class CreateCampaignVariablesTable extends Migration
$table
->
timestamps
();
$table
->
timestamps
();
$table
->
foreign
(
'campaign_id'
)
->
references
(
'id'
)
->
on
(
'campaigns'
);
$table
->
foreign
(
'campaign_id'
)
->
references
(
'id'
)
->
on
(
'campaigns'
)
$table
->
foreign
(
'variable_id'
)
->
references
(
'id'
)
->
on
(
'variables'
);
->
cascadeOnDelete
();
$table
->
foreign
(
'variable_id'
)
->
references
(
'id'
)
->
on
(
'variables'
)
->
cascadeOnDelete
();
});
});
}
}
...
...
resources/js/Pages/CampaignVariables/Edit.vue
View file @
12de07a
<
template
>
<
template
>
<div>
<div>
<h1
class=
"mb-8 font-bold text-3xl"
>
Campaign variables
</h1>
<h1
class=
"mb-8 font-bold text-3xl"
>
<inertia-link
class=
"text-indigo-400 hover:text-indigo-600"
:href=
"route('tokens')"
>
Tokens
</inertia-link>
<span
class=
"text-indigo-400 font-medium"
>
/
</span>
<inertia-link
class=
"text-indigo-400 hover:text-indigo-600"
:href=
"route('token.edit', token.id)"
>
{{
token
.
login
}}
</inertia-link>
<span
class=
"text-indigo-400 font-medium"
>
/
</span>
{{
campaign
.
name
}}
</h1>
<div
class=
"mb-6 flex justify-between items-center"
>
<div
class=
"mb-6 flex justify-between items-center"
>
<div
class=
"mt-4 flex flex-wrap"
>
<div
class=
"mt-4 flex flex-wrap"
>
<select-input
v-model=
"variable"
<select-input
v-model=
"variable"
...
@@ -21,10 +31,17 @@
...
@@ -21,10 +31,17 @@
label=
"New variable name"
label=
"New variable name"
>
>
</text-input>
</text-input>
<text-input
v-if=
"variable === 'add'"
v-model=
"default_value"
:error=
"errors.default_value"
class=
"pr-6"
label=
"New variable default value"
>
</text-input>
<text-input
v-model=
"value"
<text-input
v-model=
"value"
:error=
"errors.value"
:error=
"errors.value"
class=
"pr-6"
class=
"pr-6"
label=
"
D
efault value"
label=
"
Campaign d
efault value"
>
>
</text-input>
</text-input>
<button
class=
"btn-indigo hover:underline"
<button
class=
"btn-indigo hover:underline"
...
@@ -42,23 +59,39 @@
...
@@ -42,23 +59,39 @@
<th
class=
"px-6 pt-6 pb-4"
>
Name
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Name
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Default value
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Default value
</th>
</tr>
</tr>
<tr
v-for=
"variable in
campaign.
variables"
:key=
"variable.id"
class=
"hover:bg-gray-100 focus-within:bg-gray-100"
>
<tr
v-for=
"variable in variables"
:key=
"variable.id"
class=
"hover:bg-gray-100 focus-within:bg-gray-100"
>
<td
class=
"px-6 py-4 border-t"
>
<td
class=
"px-6 py-4 border-t"
>
<div
v-if=
"!inputs[variable.id] || !inputs[variable.id].name || !inputs[variable.id].name.editable"
<div
class=
"hover:text-indigo-500 focus:text-indigo-500 cursor-pointer"
v-if=
"!inputs[variable.id] || !inputs[variable.id].name || !inputs[variable.id].name.editable"
@
click=
"edit(variable.id, 'name', variable.name)"
class=
"hover:text-indigo-500 focus:text-indigo-500 cursor-pointer"
@
click=
"edit(variable.id, [
{
name: 'default_value',
val: variable.default_value,
},
{
name: 'name',
val: variable.name,
}
])"
>
>
{{
variable
.
name
}}
{{
variable
.
name
}}
</div>
</div>
<div
v-else
class=
"inline-flex"
>
<div
v-else
class=
"inline-flex"
>
<text-input
v-model=
"inputs[variable.id].name.val"
<text-input
v-model=
"inputs[variable.id].name.val"
class=
"pr-6"
class=
"pr-6"
label=
"Variable name"
>
</text-input>
<text-input
v-model=
"inputs[variable.id].default_value.val"
class=
"pr-6"
label=
"Variable default value"
>
>
</text-input>
</text-input>
<button
class=
"btn-indigo hover:underline mr-6"
<button
class=
"btn-indigo hover:underline mr-6"
tabindex=
"-1"
tabindex=
"-1"
type=
"button"
type=
"button"
@
click=
"save(variable.id,
'name'
)"
@
click=
"save(variable.id,
['name', 'default_value']
)"
>
>
Save
Save
...
@@ -74,21 +107,32 @@
...
@@ -74,21 +107,32 @@
</div>
</div>
</td>
</td>
<td
class=
"px-6 py-4 border-t"
>
<td
class=
"px-6 py-4 border-t"
>
<div
v-if=
"!inputs[variable.id] || !inputs[variable.id].value || !inputs[variable.id].value.editable"
<div
class=
"hover:text-indigo-500 focus:text-indigo-500 cursor-pointer"
v-if=
"!inputs[variable.id] || !inputs[variable.id].value || !inputs[variable.id].value.editable"
@
click=
"edit(variable.id, 'value', variable.pivot.value)"
class=
"hover:text-indigo-500 focus:text-indigo-500 cursor-pointer"
@
click=
"edit(variable.id, [
{
name: 'value',
val: !variable.campaign
? ''
: variable.campaign.pivot.value,
},
])"
>
>
{{
variable
.
pivot
.
value
}}
{{
!
variable
.
campaign
?
variable
.
default_value
:
variable
.
campaign
.
pivot
.
value
}}
</div>
</div>
<div
v-else
class=
"inline-flex"
>
<div
v-else
class=
"inline-flex"
>
<text-input
v-model=
"inputs[variable.id].value.val"
<text-input
v-model=
"inputs[variable.id].value.val"
class=
"pr-6"
class=
"pr-6"
label=
"Campaign default value"
>
>
</text-input>
</text-input>
<button
class=
"btn-indigo hover:underline mr-6"
<button
class=
"btn-indigo hover:underline mr-6"
tabindex=
"-1"
tabindex=
"-1"
type=
"button"
type=
"button"
@
click=
"save(variable.id,
'value'
)"
@
click=
"save(variable.id,
['value']
)"
>
>
Save
Save
...
@@ -113,8 +157,8 @@
...
@@ -113,8 +157,8 @@
</button>
</button>
</td>
</td>
</tr>
</tr>
<tr
v-if=
"
campaign.
variables.length === 0"
>
<tr
v-if=
"variables.length === 0"
>
<td
class=
"border-t px-6 py-4"
colspan=
"4"
>
No
campaign
variables found.
</td>
<td
class=
"border-t px-6 py-4"
colspan=
"4"
>
No variables found.
</td>
</tr>
</tr>
</table>
</table>
</div>
</div>
...
@@ -128,7 +172,9 @@
...
@@ -128,7 +172,9 @@
import
SelectInput
from
"../../Shared/SelectInput"
;
import
SelectInput
from
"../../Shared/SelectInput"
;
export
default
{
export
default
{
metaInfo
:
{
title
:
'Campaign variables'
},
metaInfo
()
{
return
{
title
:
this
.
campaign
.
name
}
},
components
:
{
components
:
{
Icon
,
Icon
,
TextInput
,
TextInput
,
...
@@ -144,17 +190,18 @@
...
@@ -144,17 +190,18 @@
data
()
{
data
()
{
return
{
return
{
variable
:
this
.
variables
.
length
?
null
:
'add'
,
variable
:
this
.
variables
.
length
?
null
:
'add'
,
default_value
:
''
,
name
:
''
,
name
:
''
,
value
:
''
,
value
:
''
,
inputs
:
{},
inputs
:
{},
}
}
},
},
watch
:
{
watch
:
{},
},
methods
:
{
methods
:
{
add
()
{
add
()
{
this
.
$inertia
.
post
(
this
.
route
(
'token.campaign.variables'
,
[
this
.
token
.
id
,
this
.
campaign
.
id
]),
{
this
.
$inertia
.
post
(
this
.
route
(
'token.campaign.variables'
,
[
this
.
token
.
id
,
this
.
campaign
.
id
]),
{
variable
:
this
.
variable
,
variable
:
this
.
variable
,
default_value
:
this
.
default_value
,
name
:
this
.
name
,
name
:
this
.
name
,
value
:
this
.
value
,
value
:
this
.
value
,
});
});
...
@@ -162,17 +209,19 @@
...
@@ -162,17 +209,19 @@
this
.
name
=
''
;
this
.
name
=
''
;
this
.
value
=
''
;
this
.
value
=
''
;
},
},
edit
(
campaign_var_id
,
key
,
val
)
{
edit
(
campaign_var_id
,
options
)
{
this
.
inputs
=
{
options
.
map
((
option
)
=>
{
...
this
.
inputs
,
this
.
inputs
=
{
[
campaign_var_id
]:
{
...
this
.
inputs
,
...
this
.
inputs
[
campaign_var_id
],
[
campaign_var_id
]:
{
[
key
]:
{
...
this
.
inputs
[
campaign_var_id
],
editable
:
true
,
[
option
.
name
]:
{
val
:
val
,
editable
:
true
,
val
:
option
.
val
,
}
}
}
}
}
;
};
}
)
;
},
},
editCancel
(
campaign_var_id
,
key
)
{
editCancel
(
campaign_var_id
,
key
)
{
this
.
inputs
=
{
this
.
inputs
=
{
...
@@ -186,22 +235,26 @@
...
@@ -186,22 +235,26 @@
}
}
};
};
},
},
save
(
campaign_var_id
,
key
)
{
save
(
campaign_var_id
,
names
)
{
const
method
=
key
===
'name'
?
'post'
const
method
=
names
.
indexOf
(
'name'
)
!==
-
1
:
'patch'
;
?
'patch'
:
'put'
;
this
.
$inertia
[
method
](
this
.
route
(
'token.campaign.variables'
,
[
this
.
token
.
id
,
this
.
campaign
.
id
]),
{
let
data
=
{
id
:
campaign_var_id
,
id
:
campaign_var_id
,
[
key
]:
this
.
inputs
[
campaign_var_id
][
key
].
val
,
};
names
.
map
((
name
)
=>
{
data
[
name
]
=
this
.
inputs
[
campaign_var_id
][
name
].
val
;
this
.
editCancel
(
campaign_var_id
,
name
);
});
});
this
.
editCancel
(
campaign_var_id
,
key
);
this
.
$inertia
[
method
](
this
.
route
(
'token.campaign.variables'
,
[
this
.
token
.
id
,
this
.
campaign
.
id
]),
data
);
},
},
destroy
(
campaign_var_id
)
{
destroy
(
campaign_var_id
)
{
if
(
confirm
(
'Are you sure you want to delete this campaign var?'
))
{
if
(
confirm
(
'Are you sure you want to delete this campaign var?'
))
{
this
.
$inertia
.
delete
(
this
.
route
(
'token.campaign.variables'
,
[
this
.
token
.
id
,
this
.
campaign
.
id
]),
{
this
.
$inertia
.
delete
(
this
.
route
(
'token.campaign.variable.destroy'
,
[
this
.
token
.
id
,
this
.
campaign
.
id
,
campaign_var_id
]));
id
:
campaign_var_id
,
});
}
}
},
},
},
},
...
...
resources/js/Pages/Tokens/CitySettings.vue
View file @
12de07a
...
@@ -75,14 +75,7 @@
...
@@ -75,14 +75,7 @@
type=
"checkbox"
type=
"checkbox"
>
>
</td>
</td>
<td
class=
"border-t"
>
<td
class=
"border-t"
></td>
<inertia-link
class=
"px-4 flex items-center"
tabindex=
"-1"
:href=
"route('token.campaign.variables', [token.id, campaign.id])"
>
<icon
name=
"book"
class=
"block w-6 h-6 fill-gray-400"
/>
</inertia-link>
</td>
</tr>
</tr>
</
template
>
</
template
>
<tr
v-if=
"token.cities.length === 0"
>
<tr
v-if=
"token.cities.length === 0"
>
...
...
routes/web.php
View file @
12de07a
...
@@ -180,9 +180,13 @@ Route::post('token/campaigns/managed/{token}/{campaign_id}', [TokensController::
...
@@ -180,9 +180,13 @@ Route::post('token/campaigns/managed/{token}/{campaign_id}', [TokensController::
Route
::
post
(
'token/campaigns/enabled/{token}/{campaign_id}'
,
[
TokensController
::
class
,
'enabledCampaign'
])
Route
::
post
(
'token/campaigns/enabled/{token}/{campaign_id}'
,
[
TokensController
::
class
,
'enabledCampaign'
])
->
name
(
'token.campaign.enabled'
)
->
name
(
'token.campaign.enabled'
)
->
middleware
(
'auth'
);
->
middleware
(
'auth'
);
Route
::
any
(
'token/campaigns/vars/{token}/{campaign_id}'
,
CampaignVariablesController
::
class
)
Route
::
any
(
'token/campaigns/vars/{token}/{campaign_id}'
,
CampaignVariablesController
::
class
)
->
name
(
'token.campaign.variables'
)
->
name
(
'token.campaign.variables'
)
->
middleware
(
'auth'
);
->
middleware
(
'auth'
);
Route
::
delete
(
'token/campaigns/vars/{token}/{campaign_id}/{variable_id}'
,
[
CampaignVariablesController
::
class
,
'destroy'
])
->
name
(
'token.campaign.variable.destroy'
)
->
middleware
(
'auth'
);
Route
::
post
(
'token/city/store/{token}/{city}'
,
[
TokensController
::
class
,
'storeCity'
])
Route
::
post
(
'token/city/store/{token}/{city}'
,
[
TokensController
::
class
,
'storeCity'
])
->
name
(
'token.city.store'
)
->
name
(
'token.city.store'
)
...
...
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