pixelfed/app/Http/Controllers/Admin/AdminSettingsController.php

100 lines
2.5 KiB
PHP
Raw Normal View History

2019-02-07 18:59:38 +00:00
<?php
namespace App\Http\Controllers\Admin;
use Artisan, Cache, DB;
use Illuminate\Http\Request;
use Carbon\Carbon;
use App\{Comment, Like, Media, Page, Profile, Report, Status, User};
use App\Http\Controllers\Controller;
use App\Util\Lexer\PrettyNumber;
trait AdminSettingsController
{
public function settings(Request $request)
{
return view('admin.settings.home');
}
public function settingsBackups(Request $request)
{
2019-03-01 07:04:14 +00:00
$path = storage_path('app/'.config('app.name'));
$files = is_dir($path) ? new \DirectoryIterator($path) : [];
2019-02-07 18:59:38 +00:00
return view('admin.settings.backups', compact('files'));
}
2019-06-14 01:45:09 +00:00
public function settingsConfig(Request $request)
2019-02-07 18:59:38 +00:00
{
2019-06-14 01:45:09 +00:00
$editor = [];
2019-06-16 02:28:03 +00:00
$config = file_get_contents(base_path('.env'));
return view('admin.settings.config', compact('editor', 'config'));
2019-02-07 18:59:38 +00:00
}
public function settingsMaintenance(Request $request)
{
return view('admin.settings.maintenance');
}
public function settingsStorage(Request $request)
{
2019-03-02 02:05:14 +00:00
$storage = [];
2019-02-07 18:59:38 +00:00
return view('admin.settings.storage', compact('storage'));
}
public function settingsFeatures(Request $request)
{
return view('admin.settings.features');
}
public function settingsHomeStore(Request $request)
{
$this->validate($request, [
'APP_NAME' => 'required|string',
]);
2019-06-14 01:45:09 +00:00
// Artisan::call('config:clear');
2019-02-07 18:59:38 +00:00
return redirect()->back();
}
public function settingsPages(Request $request)
{
$pages = Page::orderByDesc('updated_at')->paginate(10);
return view('admin.pages.home', compact('pages'));
}
public function settingsPageEdit(Request $request)
{
return view('admin.pages.edit');
}
public function settingsSystem(Request $request)
{
$sys = [
'pixelfed' => config('pixelfed.version'),
'php' => phpversion(),
2019-03-01 07:16:11 +00:00
'laravel' => app()->version(),
2019-02-07 18:59:38 +00:00
];
2019-02-13 02:48:28 +00:00
switch (config('database.default')) {
case 'pgsql':
$sys['database'] = [
'name' => 'Postgres',
'version' => explode(' ', DB::select(DB::raw('select version();'))[0]->version)[1]
];
break;
case 'mysql':
$sys['database'] = [
'name' => 'MySQL',
'version' => DB::select( DB::raw("select version()") )[0]->{'version()'}
];
break;
default:
$sys['database'] = [
'name' => 'Unknown',
'version' => '?'
];
break;
}
2019-02-07 18:59:38 +00:00
return view('admin.settings.system', compact('sys'));
}
}