Files
faveo/app/Http/Controllers/Admin/helpdesk/ErrorAndDebuggingController.php
Shift 21910f2106 Apply Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions.

You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root.

For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
2023-01-06 11:53:02 +00:00

107 lines
3.0 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\helpdesk;
// controller
use App\Http\Controllers\Controller;
// request
use Exception;
use File;
use Lang;
/**
* ErrorAndDebuggingController.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class ErrorAndDebuggingController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
// $this->smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* function to show error and debugging setting page.
*
* @param void
* @return response
*/
public function showSettings()
{
$debug = \Config::get('app.debug');
$bugsnag = \Config::get('app.bugsnag_reporting');
return view('themes.default1.admin.helpdesk.settings.error-and-logs.error-debug')->with(['debug' => $debug, 'bugsnag' => $bugsnag]);
}
/**
* funtion to update error and debugging settings.
*
* @param void
* @return
*/
public function postSettings()
{
try {
$debug = \Config::get('app.debug');
$debug = ($debug) ? 'true' : 'false';
$bugsnag_debug = \Config::get('app.bugsnag_reporting');
$bugsnag_debug = ($bugsnag_debug) ? 'true' : 'false';
if ($debug != \Input::get('debug') || $bugsnag_debug != \Input::get('bugsnag')) {
// dd($request->input());
$debug_new = base_path().DIRECTORY_SEPARATOR.'.env';
$datacontent = File::get($debug_new);
$datacontent = str_replace(
'APP_DEBUG='.$debug,
'APP_DEBUG='.\Input::get('debug'),
$datacontent
);
File::put($debug_new, $datacontent);
// dd($request->input());
$bugsnag_debug_new = base_path().DIRECTORY_SEPARATOR.'.env';
$datacontent2 = File::get($bugsnag_debug_new);
$datacontent2 = str_replace(
'APP_BUGSNAG='.$bugsnag_debug,
'APP_BUGSNAG='.\Input::get('bugsnag'),
$datacontent2
);
File::put($bugsnag_debug_new, $datacontent2);
return redirect()->back()->with(
'success',
Lang::get('lang.error-debug-settings-saved-message')
);
} else {
return redirect()->back()->with(
'fails',
Lang::get('lang.error-debug-settings-error-message')
);
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* function to show error log table page.
*
* @param void
* @return response view
*/
public function showErrorLogs()
{
return view('themes.default1.admin.helpdesk.settings.error-and-logs.log-table');
}
}