-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5a16fac
Showing
8 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Intelrx\\Sitesettings\\SitesettingsProvider" | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Intelrx\Sitesettings\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Intelrx\Sitesettings\SitesettingsProvider; | ||
|
||
class configCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'config:settings'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Setups the site settings'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
// dd('configssssssss'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Intelrx\Sitesettings\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class SiteSettings extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = ['key', 'value']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Intelrx\Sitesettings; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\ValidationException; | ||
use Intelrx\Sitesettings\Models\SiteSettings; | ||
|
||
class SiteConfig extends Controller | ||
{ | ||
/** | ||
* Handle the incoming request. | ||
*/ | ||
public static function store($key, $value) | ||
{ | ||
SiteSettings::create([ | ||
'key' => $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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Intelrx\Sitesettings; | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\ServiceProvider; | ||
use Intelrx\Sitesettings\Console\Commands\configCommand; | ||
|
||
class SitesettingsProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
*/ | ||
public function register(): void | ||
{ | ||
$this->loadMigrationsFrom(__DIR__ . '/database/migrations'); | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
*/ | ||
public function boot(): void | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
$this->commands([ | ||
]); | ||
} | ||
} | ||
|
||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/database/migrations/2024_08_29_192637_create_site_settings_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('site_settings', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('key')->unique(); | ||
$table->text('value')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('site_settings'); | ||
} | ||
}; |