diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..49ce3c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a215503 --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "name": "intelrx/sitesettings", + "description": "Application global properties", + "require": { + "php": "^8.3" + }, + "license": "MIT", + "autoload": { + "psr-4": { + "Intelrx\\Sitesettings\\": "src/" + } + }, + "authors": [ + { + "name": "raza9798", + "email": "m.raza9798@gmail.com" + } + ], + "minimum-stability": "dev", + "extra": { + "laravel": { + "providers": [ + "Intelrx\\Sitesettings\\SitesettingsProvider" + ] + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..8fd6fad --- /dev/null +++ b/composer.lock @@ -0,0 +1,20 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b92bfe9d7177c9ee44d256985591f8f5", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.3" + }, + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/src/Console/Commands/configCommand.php b/src/Console/Commands/configCommand.php new file mode 100644 index 0000000..f757b52 --- /dev/null +++ b/src/Console/Commands/configCommand.php @@ -0,0 +1,31 @@ + $key, + 'value' => $value + ]); + } + + public static function get($key) + { + $data = SiteSettings::where('key', $key)->first(); + return $data ? $data->value : null; + } + + public static function update($key, $value) + { + $data = SiteSettings::where('key', $key)->first(); + if ($data) { + $data->value = $value; + $data->save(); + } + } + + public static function delete($key) + { + $data = SiteSettings::where('key', $key)->first(); + if ($data) { + $data->delete(); + } + } +} diff --git a/src/SitesettingsProvider.php b/src/SitesettingsProvider.php new file mode 100644 index 0000000..855b907 --- /dev/null +++ b/src/SitesettingsProvider.php @@ -0,0 +1,31 @@ +loadMigrationsFrom(__DIR__ . '/database/migrations'); + } + + /** + * Bootstrap services. + */ + public function boot(): void + { + if ($this->app->runningInConsole()) { + $this->commands([ + ]); + } + } + + +} diff --git a/src/database/migrations/2024_08_29_192637_create_site_settings_table.php b/src/database/migrations/2024_08_29_192637_create_site_settings_table.php new file mode 100644 index 0000000..1189c97 --- /dev/null +++ b/src/database/migrations/2024_08_29_192637_create_site_settings_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('key')->unique(); + $table->text('value')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('site_settings'); + } +};