forked from projects/fipamo
ro
064407aa88
a class for members was needed for long term handling of member functions like login, update, status checking, etc so that class was created and the AuthService class was removed as it was redundant and it's functionaity moved to the member class
77 lines
2.3 KiB
PHP
77 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\SettingsService;
|
|
use App\Services\RenderService;
|
|
use App\Services\MaintenanceService;
|
|
use App\Interfaces\MemberRepositoryInterface;
|
|
use App\Services\AssetService;
|
|
|
|
class SettingsAPIController extends Controller
|
|
{
|
|
protected $settings;
|
|
protected $render;
|
|
protected $mainteance;
|
|
protected $member;
|
|
protected $assets;
|
|
|
|
public function __construct(
|
|
SettingsService $settingsService,
|
|
RenderService $renderService,
|
|
MaintenanceService $maintenanceService,
|
|
MemberRepositoryInterface $memberRepo,
|
|
AssetService $assetService
|
|
) {
|
|
$this->settings = $settingsService;
|
|
$this->render = $renderService;
|
|
$this->maintenance = $maintenanceService;
|
|
$this->member = $memberRepo;
|
|
$this->assets = $assetService;
|
|
}
|
|
|
|
public function publish(Request $request)
|
|
{
|
|
$this->assets->moveToTheme(true);
|
|
$result = $this->render->publishAll();
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function sync(Request $request)
|
|
{
|
|
$body = json_decode($request->getContent());
|
|
$result = $this->settings->sync($body);
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function navSync(Request $request)
|
|
{
|
|
$body = json_decode($request->getContent());
|
|
$result = $this->settings->navSync($body);
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function createBackup(Request $request)
|
|
{
|
|
return response()->json($this->maintenance->createBackup())->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function downloadBackup(Request $request)
|
|
{
|
|
if ($this->member::status()) {
|
|
$latest = $this->settings->getGlobal()['last_backup'];
|
|
$file = 'backup-' . $latest . '.zip';
|
|
return response()->download('../content/backups/' . $file, $file, ['Content-Type: application/zip']);
|
|
}
|
|
}
|
|
|
|
//init stuff
|
|
public function setupFresh(Request $request)
|
|
{
|
|
$body = json_decode($request->getContent());
|
|
dd($body);
|
|
}
|
|
}
|