This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccount/app/Http/Controllers/API/ServerController.php

35 lines
976 B
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\API;
use App\Exceptions\HTTPException;
use App\Exceptions\NoPermissionException;
use App\Exceptions\NotLoggedInException;
use App\Exceptions\ResourceNotFound;
use App\Models\Setting;
use App\Models\User;
2019-07-18 08:18:08 +00:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Laravel\Lumen\Routing\Controller as BaseController;
use TaGeSo\APIResponse\Response;
class ServerController extends BaseController
{
2019-07-18 08:18:08 +00:00
public function getSettings(Request $request,Response $response) {
$settings = Setting::getPublicSettings();
2019-07-18 08:18:08 +00:00
if($request->input("all") == true) {
if(!Auth::check()) {
throw new NotLoggedInException();
}
if(!Auth::user()->admin) {
throw new NoPermissionException();
}
$settings = Setting::all();
}
return $response->withData(\App\Http\Resources\API\Setting::collection(collect($settings)));
}
}