chore: code refactor via rector
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Session;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use App\Models\Premium;
|
||||
use App\Models\ZEmail;
|
||||
use Session;
|
||||
|
||||
class AppController extends Controller
|
||||
{
|
||||
@@ -15,67 +17,66 @@ class AppController extends Controller
|
||||
'email' => 'required|email',
|
||||
])->validate();
|
||||
|
||||
if (json_decode(config('app.settings.configuration_settings'))->enable_create_from_url) {
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->enable_create_from_url) {
|
||||
ZEmail::createCustomEmailFull($email);
|
||||
}
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
if (! ZEmail::getEmail()) {
|
||||
return redirect()->route('home');
|
||||
return to_route('home');
|
||||
}
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return redirect()->route('home');
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
return $this->app();
|
||||
}
|
||||
|
||||
public function app()
|
||||
public function app(): Redirector|RedirectResponse
|
||||
{
|
||||
return redirect()->route('home');
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
public function switch($email)
|
||||
public function switch($email): Redirector|RedirectResponse
|
||||
{
|
||||
ZEmail::setEmail($email);
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return redirect()->route('home');
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
|
||||
public function delete($email = null)
|
||||
public function delete($email = null): Redirector|RedirectResponse
|
||||
{
|
||||
if ($email) {
|
||||
$emails = ZEmail::getEmails();
|
||||
ZEmail::removeEmail($email);
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
} else {
|
||||
return redirect()->route('home');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
public function switchP($email)
|
||||
public function switchP($email): Redirector|RedirectResponse
|
||||
{
|
||||
if (Session::get('isInboxTypePremium')) {
|
||||
if (\Illuminate\Support\Facades\Session::get('isInboxTypePremium')) {
|
||||
Premium::setEmailP($email);
|
||||
} else {
|
||||
ZEmail::setEmail($email);
|
||||
}
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return redirect()->route('dashboard');
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return to_route('dashboard');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
|
||||
public function deleteP($email = null)
|
||||
public function deleteP($email = null): Redirector|RedirectResponse
|
||||
{
|
||||
if ($email) {
|
||||
if (Session::get('isInboxTypePremium')) {
|
||||
if (\Illuminate\Support\Facades\Session::get('isInboxTypePremium')) {
|
||||
$emails = Premium::getEmails();
|
||||
Premium::removeEmail($email);
|
||||
} else {
|
||||
@@ -83,10 +84,9 @@ class AppController extends Controller
|
||||
ZEmail::removeEmail($email);
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
} else {
|
||||
return redirect()->route('dashboard');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
return to_route('dashboard');
|
||||
}
|
||||
|
||||
public function locale($locale)
|
||||
@@ -94,38 +94,8 @@ class AppController extends Controller
|
||||
if (in_array($locale, config('app.locales'))) {
|
||||
session(['locale' => $locale]);
|
||||
|
||||
return redirect()->back();
|
||||
return back();
|
||||
}
|
||||
abort(400);
|
||||
}
|
||||
|
||||
private function getStringBetween($string, $start, $end)
|
||||
{
|
||||
$string = ' '.$string;
|
||||
$ini = strpos($string, $start);
|
||||
if ($ini == 0) {
|
||||
return '';
|
||||
}
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
|
||||
return substr($string, $ini, $len);
|
||||
}
|
||||
|
||||
private function setHeaders($page)
|
||||
{
|
||||
$header = $page->header;
|
||||
foreach ($page->meta ? unserialize($page->meta) : [] as $meta) {
|
||||
if ($meta['name'] == 'canonical') {
|
||||
$header .= '<link rel="canonical" href="'.$meta['content'].'" />';
|
||||
} elseif (str_contains($meta['name'], 'og:')) {
|
||||
$header .= '<meta property="'.$meta['name'].'" content="'.$meta['content'].'" />';
|
||||
} else {
|
||||
$header .= '<meta name="'.$meta['name'].'" content="'.$meta['content'].'" />';
|
||||
}
|
||||
}
|
||||
$page->header = $header;
|
||||
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user