Skip to content

Commit

Permalink
Introduce settings group
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Jan 9, 2025
1 parent 7ebdf0a commit d7c175a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
4 changes: 3 additions & 1 deletion app/Model/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function assignAll(){

}


public function scopeGroup($query, $group){
return $query->where('group', $group);
}

}
8 changes: 3 additions & 5 deletions app/Model/UserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ public function users(){
}

public function addRight($right){
$all_rights = $this->getRightsAttribute();
$all_rights = $this->rights;
array_push($all_rights, $right);
$this->setRightsAttribute($all_rights);
$this->rights = $all_rights;
}

public function isAdminRole(){
$roles = $this->attributes['rights'];

return $roles? in_array('admin_area',$roles) : false;
return $this->rights? in_array('admin_area',$this->rights) : false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function up()

Schema::create($this->table_name, function (Blueprint $table) {
$table->increments('id');
$table->string('group')->nullable();
$table->string('setting')->comment("Key");
$table->string('value',4000)->nullable()->comment("Value");
$table->timestamps();
$table->boolean('more')->default(NULL);
});
}

Expand Down
38 changes: 38 additions & 0 deletions database/seeders/SettingsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,230 +17,268 @@ public function run()
{

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'title',
'value' => "Your title",
'more' => '1',
]);


DB::table('settings')->insert([
'group' => 'website',
'setting' => 'site_name',
'value' => "Your site",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'slogan',
'value' => "Your awesome slogan",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'favicon',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'scroll_text',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'default_email',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'address',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'default_phone',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'contact',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'theme',
'value' => 'TheWright',
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'language',
'value' => 'en',
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'date_format',
'value' => "Y.m.d H:i:s",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'home_page',
'value' => 1,
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'website_down',
'value' => "0",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'logo',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'favicon',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'admin',
'setting' => 'admin_logo',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'website_debug',
'value' => "0",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'admin',
'setting' => 'admin_debug',
'value' => "0",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'admin',
'setting' => 'admin_broadcast',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'website_type',
'value' => "website",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'blogposts_on_page',
'value' => "5",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'admin',
'setting' => 'default_user_role',
'value' => "2",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'admin',
'setting' => 'auto_upgrade_check',
'value' => "1",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'use_https',
'value' => "0",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_facebook',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_youtube',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_twitter',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_instagram',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_google',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_linkedin',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_github',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_gitlab',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_spotify',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_soundcloud',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_steam',
'value' => "",
'more' => '1',
]);

DB::table('settings')->insert([
'group' => 'website',
'setting' => 'social_link_reddit',
'value' => "",
'more' => '1',
]);


DB::table('settings')->insert([
'group' => 'admin',
'setting' => 'scheduler',
'value' => "not configured",
'more' => '1',
Expand Down
8 changes: 8 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
Route::apiResource('header-images', \App\Controllers\HeaderImageController::class)
->only(['index', 'show']);

Route::get('/settings', function(Request $request){

$settings = \App\Model\Settings::group('website')->get();

return response()->json($settings);

});

Route::get('/users',function(Request $request){

if(\Auth::user()->hasPermission("users")){
Expand Down

0 comments on commit d7c175a

Please sign in to comment.