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 c3c8ed1f
authored
May 18, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
1 parent
3655103f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
app/Http/Controllers/CampaignVariablesController.php
app/Http/Controllers/CampaignVariablesController.php
View file @
c3c8ed1
...
...
@@ -4,6 +4,8 @@ namespace App\Http\Controllers;
use
App\Models\Tokens
;
use
App\Models\Variable
;
use
Illuminate\Support\Facades\Redirect
;
use
Illuminate\Support\Facades\Request
;
use
Inertia\Inertia
;
class
CampaignVariablesController
extends
Controller
...
...
@@ -16,13 +18,13 @@ class CampaignVariablesController extends Controller
function
__invoke
(
Tokens
$token
,
$campaign_id
)
{
if
(
$token
->
isMain
())
{
return
back
();
return
Redirect
::
back
();
}
$campaign
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
get
()
->
first
()
->
campaignsForEnabled
()
->
with
(
'variables'
)
->
find
(
$campaign_id
);
if
(
!
$campaign
)
{
return
back
();
return
Redirect
::
back
();
};
switch
(
request
()
->
method
())
{
...
...
@@ -36,7 +38,7 @@ class CampaignVariablesController extends Controller
case
'POST'
:
if
(
request
(
'variable'
)
===
'add'
)
{
request
()
->
validate
([
Request
::
validate
([
'name'
=>
$this
->
rule_variable_name
,
'value'
=>
$this
->
rule_value
,
]);
...
...
@@ -47,7 +49,7 @@ class CampaignVariablesController extends Controller
$variable_id
=
$variable_new
->
getKey
();
$value
=
request
(
'value'
);
}
else
{
request
()
->
validate
([
Request
::
validate
([
'variable'
=>
$this
->
rule_variable
,
'value'
=>
$this
->
rule_value
,
]);
...
...
@@ -61,7 +63,7 @@ class CampaignVariablesController extends Controller
],
]);
return
back
()
->
with
(
'success'
,
'Campaign variable added.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable added.'
);
break
;
case
'PUT'
:
...
...
@@ -69,14 +71,14 @@ class CampaignVariablesController extends Controller
$campaign_variable
=
$campaign
->
variables
()
->
find
(
request
(
'id'
));
if
(
!
$campaign_variable
)
{
return
back
();
return
Redirect
::
back
();
}
if
(
request
()
->
validate
([
'name'
=>
$this
->
rule_variable_name
]))
{
$campaign_variable
->
update
(
request
()
->
only
(
'name'
));
}
$campaign_variable
->
update
([
Request
::
validate
([
'name'
=>
$this
->
rule_variable_name
])
]);
return
back
()
->
with
(
'success'
,
'Variable name updated.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Variable name updated.'
);
break
;
...
...
@@ -85,14 +87,14 @@ class CampaignVariablesController extends Controller
$campaign_variable
=
$campaign
->
variables
()
->
find
(
request
(
'id'
));
if
(
!
$campaign_variable
)
{
return
back
();
return
Redirect
::
back
();
}
if
(
request
()
->
validate
([
'value'
=>
$this
->
rule_value
]))
{
$campaign_variable
->
update
(
request
()
->
only
(
'value'
));
}
return
back
()
->
with
(
'success'
,
'Campaign variable updated.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable updated.'
);
break
;
case
'DELETE'
:
...
...
@@ -100,15 +102,15 @@ class CampaignVariablesController extends Controller
$campaign_variable
=
$campaign
->
vars
()
->
find
(
request
(
'id'
));
if
(
!
$campaign_variable
)
{
return
back
();
return
Redirect
::
back
();
}
$campaign_variable
->
delete
();
return
back
()
->
with
(
'success'
,
'Campaign variable deleted.'
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign variable deleted.'
);
break
;
}
return
back
();
return
Redirect
::
back
();
}
}
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