kuvia/app/Http/Controllers/AdminController.php

42 lines
1.4 KiB
PHP
Raw Normal View History

2021-01-21 17:56:30 +00:00
<?php
namespace App\Http\Controllers;
2021-02-09 18:00:04 +00:00
use App\Models\Server;
2021-01-21 17:56:30 +00:00
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;
2021-02-09 18:00:04 +00:00
use Illuminate\Support\Facades\Auth;
2021-01-21 17:56:30 +00:00
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();
2021-02-09 18:00:04 +00:00
}
2021-01-21 17:56:30 +00:00
2021-02-09 18:00:04 +00:00
public function serverView() {
if(Auth::user()->typ != "admin") {
abort(401);
}
$servers = Server::query()->get();
return view("admin.servers", ["servers" => $servers]);
2021-01-21 17:56:30 +00:00
}
}