kuvia/app/Http/Controllers/AdminController.php
2021-02-09 19:00:04 +01:00

41 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Server;
use App\Models\Theme;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
class AdminController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function themesView() {
$themes = Theme::query()->get();
return view("admin.themes", ["themes" => $themes]);
}
public function themesSettings(Request $request) {
$theme = Theme::query()->where("id", "=", $request->input("id"))->firstOrFail();
$theme->status = $request->input("status");
$theme->img_big = (bool)$request->input("img_big", false);
$theme->img_medium = (bool)$request->input("img_medium", false);
$theme->img_small = (bool)$request->input("img_small", false);
$theme->img_pixel = (bool)$request->input("img_pixel", false);
$theme->saveOrFail();
return Redirect::back();
}
public function serverView() {
if(Auth::user()->typ != "admin") {
abort(401);
}
$servers = Server::query()->get();
return view("admin.servers", ["servers" => $servers]);
}
}