Skip to content

Commit

Permalink
bumped to 1.1.1-alpha and added brand settings
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jun 29, 2023
1 parent 984225f commit 72853c2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/core-api",
"version": "1.1.0-alpha",
"version": "1.1.1-alpha",
"description": "Core Framework and Resources for Fleetbase API",
"keywords": [
"fleetbase",
Expand Down
36 changes: 36 additions & 0 deletions src/Http/Controllers/Internal/v1/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,40 @@ public function saveServicesConfig(Request $request)

return response()->json(['status' => 'OK']);
}

/**
* Get branding settings.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function getBrandingSettings()
{
$brandingSettings = Setting::getBranding();
return response()->json(['brand' => $brandingSettings]);
}

/**
* Saves branding settings.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function saveBrandingSettings(Request $request)
{
$iconUrl = $request->input('brand.icon_url');
$logoUrl = $request->input('brand.logo_url');

if ($iconUrl) {
Setting::configure('branding.icon_url', $iconUrl);
}

if ($logoUrl) {
Setting::configure('branding.logo_url', $logoUrl);
}

$brandingSettings = Setting::getBranding();

return response()->json(['brand' => $brandingSettings]);
}
}
11 changes: 11 additions & 0 deletions src/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,15 @@ public static function configure($key, $value = null)
]
);
}

public static function getBranding()
{
$brandingSettings = ['id' => 1, 'uuid' => 1];
$iconUrl = static::where('key', 'branding.icon_url')->first();
$logoUrl = static::where('key', 'branding.logo_url')->first();
$brandingSettings['icon_url'] = $iconUrl ? $iconUrl->value : '/images/icon.png';
$brandingSettings['logo_url'] = $logoUrl ? $logoUrl->value : '/images/fleetbase-logo-svg.svg';

return $brandingSettings;
}
}
8 changes: 8 additions & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ function ($router) {
$router->get('font-awesome-icons', 'LookupController@fontAwesomeIcons');
}
);
$router->group(
['prefix' => 'settings'],
function ($router) {
$router->get('branding', 'SettingController@getBrandingSettings');
}
);
$router->group(
['middleware' => ['fleetbase.protected']],
function ($router) {
Expand All @@ -83,6 +89,8 @@ function ($router, $controller) {
$router->post('queue-config', $controller('saveQueueConfig'));
$router->get('services-config', $controller('getServicesConfig'));
$router->post('services-config', $controller('saveServicesConfig'));
$router->post('branding', $controller('saveBrandingSettings'));
$router->put('branding', $controller('saveBrandingSettings'));
}
);
$router->fleetbaseRoutes('api-events');
Expand Down

0 comments on commit 72853c2

Please sign in to comment.