refactor: simplify ifelse to ternary

This commit is contained in:
HDVinnie
2020-02-13 17:30:47 -05:00
parent 4bf3b00bfc
commit 6eaeb07fc1
11 changed files with 52 additions and 260 deletions
+7 -35
View File
@@ -27,11 +27,7 @@ class TopicLabelController extends Controller
public function approve($id)
{
$topic = Topic::findOrFail($id);
if ($topic->approved == 0) {
$topic->approved = '1';
} else {
$topic->approved = '0';
}
$topic->approved = $topic->approved == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])
@@ -48,11 +44,7 @@ class TopicLabelController extends Controller
public function deny($id)
{
$topic = Topic::findOrFail($id);
if ($topic->denied == 0) {
$topic->denied = '1';
} else {
$topic->denied = '0';
}
$topic->denied = $topic->denied == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])
@@ -69,11 +61,7 @@ class TopicLabelController extends Controller
public function solve($id)
{
$topic = Topic::findOrFail($id);
if ($topic->solved == 0) {
$topic->solved = '1';
} else {
$topic->solved = '0';
}
$topic->solved = $topic->solved == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])
@@ -90,11 +78,7 @@ class TopicLabelController extends Controller
public function invalid($id)
{
$topic = Topic::findOrFail($id);
if ($topic->invalid == 0) {
$topic->invalid = '1';
} else {
$topic->invalid = '0';
}
$topic->invalid = $topic->invalid == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])
@@ -111,11 +95,7 @@ class TopicLabelController extends Controller
public function bug($id)
{
$topic = Topic::findOrFail($id);
if ($topic->bug == 0) {
$topic->bug = '1';
} else {
$topic->bug = '0';
}
$topic->bug = $topic->bug == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])
@@ -132,11 +112,7 @@ class TopicLabelController extends Controller
public function suggest($id)
{
$topic = Topic::findOrFail($id);
if ($topic->suggestion == 0) {
$topic->suggestion = '1';
} else {
$topic->suggestion = '0';
}
$topic->suggestion = $topic->suggestion == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])
@@ -153,11 +129,7 @@ class TopicLabelController extends Controller
public function implement($id)
{
$topic = Topic::findOrFail($id);
if ($topic->implemented == 0) {
$topic->implemented = '1';
} else {
$topic->implemented = '0';
}
$topic->implemented = $topic->implemented == 0 ? '1' : '0';
$topic->save();
return redirect()->route('forum_topic', ['id' => $topic->id])