Files
wticreatorstudio/Modules/StaffPortal/Http/Controllers/DashboardCardsController.php
T
2024-02-12 22:54:20 -05:00

146 lines
4.4 KiB
PHP

<?php
namespace Modules\StaffPortal\Http\Controllers;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\StaffPortal\Repositories\SettingsRepository;
use Modules\StaffPortal\Services\AugmentationService;
class DashboardCardsController extends Controller
{
private $settings_repository;
public function __construct(SettingsRepository $settings_repository)
{
$this->settings_repository = $settings_repository;
}
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index()
{
return view('staffportal::manage_dashboard_cards');
}
/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('staffportal::create');
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Renderable
*/
public function store(Request $request)
{
//
}
/**
* Show the specified resource.
* @param int $id
* @return Renderable
*/
public function show($id)
{
return view('staffportal::show');
}
/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('staffportal::edit');
}
/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
public function getDashboardCardsSettings(Request $request) {
$group = 'dashboard_cards';
return $this->settings_repository->getGroup($group);
}
public function saveDashboardCardsSettings(Request $request) {
$group = 'dashboard_cards';
if ($request->has('type')) {
$this->settings_repository->update($group, 'background_type', $request->type);
}
if ($request->has('normalBackgroundColor')) {
$this->settings_repository->update($group, 'normal_background_color', $request->normalBackgroundColor);
}
if ($request->has('hoverBackgroundColor')) {
$this->settings_repository->update($group, 'hover_background_color', $request->hoverBackgroundColor);
}
if ($request->has('normalBackgroundGradient')) {
$this->settings_repository->update($group, 'normal_background_gradient', $request->normalBackgroundGradient);
}
if ($request->has('hoverBackgroundGradient')) {
$this->settings_repository->update($group, 'hover_background_gradient', $request->hoverBackgroundGradient);
}
if ($request->has('normalBackgroundGradientType')) {
$this->settings_repository->update($group, 'normal_background_gradient_type', $request->normalBackgroundGradientType);
}
if ($request->has('hoverBackgroundGradientType')) {
$this->settings_repository->update($group, 'hover_background_gradient_type', $request->hoverBackgroundGradientType);
}
if ($request->has('normalBackgroundGradientDirection')) {
$this->settings_repository->update($group, 'normal_background_gradient_direction', $request->normalBackgroundGradientDirection);
}
if ($request->has('hoverBackgroundGradientDirection')) {
$this->settings_repository->update($group, 'hover_background_gradient_direction', $request->hoverBackgroundGradientDirection);
}
if ($request->has('normalBackgroundImage')) {
$this->settings_repository->update($group, 'normal_background_image', $request->normalBackgroundImage);
}
if ($request->has('hoverBackgroundImage')) {
$this->settings_repository->update($group, 'hover_background_image', $request->hoverBackgroundImage);
}
return response()->json([
'message' => 'Dashboard Cards Settings has been saved.'
]);
}
}