added get_settings_in_json helper

This commit is contained in:
Peter Papp
2021-03-12 14:35:12 +01:00
parent af5181d4d7
commit 8ef5444136
2 changed files with 16 additions and 8 deletions

View File

@@ -67,11 +67,7 @@ class AppFunctionsController extends Controller
$pages = Page::all();
// Get all settings
$settings = json_decode(
Setting::all()
->pluck('value', 'name')
->toJson()
);
$settings = get_settings_in_json();
} catch (PDOException $e) {
@@ -92,7 +88,7 @@ class AppFunctionsController extends Controller
public function og_site($token)
{
// Get all settings
$settings = Setting::all();
$settings = get_settings_in_json();
// Get shared token
$shared = get_shared($token);
@@ -105,7 +101,7 @@ class AppFunctionsController extends Controller
// Get file record
$file = File::where('user_id', $shared->user_id)
->where('unique_id', $shared->item_id)
->where('id', $shared->item_id)
->first();
if ($file->thumbnail) {
@@ -142,7 +138,7 @@ class AppFunctionsController extends Controller
// Return view
return view("og-view")
->with('settings', json_decode($settings->pluck('value', 'name')->toJson()))
->with('settings', $settings)
->with('metadata', $metadata);
}

View File

@@ -38,6 +38,18 @@ function get_setting($setting)
return Setting::find($setting)->value ?? null;
}
/**
* Get all app settings and return them as json
*/
function get_settings_in_json()
{
return json_decode(
Setting::all()
->pluck('value', 'name')
->toJson()
);
}
/**
* Create paragraph from text
*