-
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
1 parent
4ed223c
commit f6e2fb3
Showing
17 changed files
with
20 additions
and
87 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
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 |
---|---|---|
|
@@ -2,10 +2,7 @@ | |
|
||
use MichaelNabil230\Setting\Models\Setting; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
|
@@ -32,7 +29,7 @@ | |
|
||
'drivers' => [ | ||
'database' => [ | ||
'driver' => MichaelNabil230\Setting\Stores\DatabaseSettingStore::class, | ||
'driver' => \MichaelNabil230\Setting\Stores\DatabaseSettingStore::class, | ||
'options' => [ | ||
'model' => Setting::class, | ||
'table' => 'settings', // name of table in dataBase | ||
|
@@ -44,7 +41,7 @@ | |
], | ||
|
||
'redis' => [ | ||
'driver' => MichaelNabil230\Setting\Stores\RedisSettingStore::class, | ||
'driver' => \MichaelNabil230\Setting\Stores\RedisSettingStore::class, | ||
'options' => [ | ||
'client' => 'predis', | ||
'default' => [ | ||
|
@@ -56,7 +53,7 @@ | |
], | ||
|
||
'json' => [ | ||
'driver' => MichaelNabil230\Setting\Stores\JsonSettingStore::class, | ||
'driver' => \MichaelNabil230\Setting\Stores\JsonSettingStore::class, | ||
'options' => [ | ||
'path' => storage_path('settings.json'), | ||
], | ||
|
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 |
---|---|---|
|
@@ -4,12 +4,6 @@ use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
/** | ||
* | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
* @package setting | ||
*/ | ||
return new class extends Migration | ||
{ | ||
public function __construct() | ||
|
@@ -22,7 +16,7 @@ return new class extends Migration | |
* | ||
* @return void | ||
*/ | ||
public function up(): void | ||
public function up() | ||
{ | ||
Schema::create($this->table, function (Blueprint $table) { | ||
$table->id(); | ||
|
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 |
---|---|---|
|
@@ -4,10 +4,6 @@ | |
|
||
use Illuminate\Console\Command; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class ForgetSetting extends Command | ||
{ | ||
/** | ||
|
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 |
---|---|---|
|
@@ -6,10 +6,6 @@ | |
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Collection; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class GetSetting extends Command | ||
{ | ||
/** | ||
|
@@ -82,7 +78,7 @@ private function print($settings) | |
$settings | ||
); | ||
|
||
$this->info('Values found '.$settings->count()); | ||
$this->info('Values found ' . $settings->count()); | ||
|
||
return Command::SUCCESS; | ||
} | ||
|
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 |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
use Illuminate\Console\Command; | ||
use Illuminate\Support\Arr; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class SetOrUpdateSetting extends Command | ||
{ | ||
/** | ||
|
@@ -38,9 +34,9 @@ public function handle() | |
$settings = setting()->set($key, $value)->save(); | ||
|
||
if (Arr::has($settings, $key)) { | ||
$this->info('Insert '.$key.' into a new setting successfully.'); | ||
$this->info('Insert ' . $key . ' into a new setting successfully.'); | ||
} else { | ||
$this->info('Updated '.$key.' setting successfully.'); | ||
$this->info('Updated ' . $key . ' setting successfully.'); | ||
} | ||
|
||
return Command::SUCCESS; | ||
|
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<?php | ||
|
||
namespace MichaelNabil230\Setting\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @method get($key, $default = null) | ||
* @method set($key, $value = null) | ||
|
@@ -15,14 +19,6 @@ | |
* @see \MichaelNabil230\Setting\SettingManager | ||
*/ | ||
|
||
namespace MichaelNabil230\Setting\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class Setting extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
|
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 |
---|---|---|
|
@@ -2,10 +2,6 @@ | |
|
||
namespace MichaelNabil230\Setting\Interfaces; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
interface Store | ||
{ | ||
/** | ||
|
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 |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class Setting extends Model | ||
{ | ||
use HasFactory; | ||
|
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 |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Manager; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class SettingManager extends Manager | ||
{ | ||
/** | ||
|
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 |
---|---|---|
|
@@ -9,10 +9,6 @@ | |
use Spatie\LaravelPackageTools\Package; | ||
use Spatie\LaravelPackageTools\PackageServiceProvider; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class SettingServiceProvider extends PackageServiceProvider | ||
{ | ||
public function configurePackage(Package $package): void | ||
|
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 |
---|---|---|
|
@@ -6,10 +6,6 @@ | |
use Illuminate\Support\Arr; | ||
use MichaelNabil230\Setting\Interfaces\Store; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
abstract class AbstractStore implements Store | ||
{ | ||
/** | ||
|
@@ -57,7 +53,7 @@ public function get($key, $default = null): mixed | |
{ | ||
$this->loadedData(); | ||
|
||
$default = $default ?? config('setting.defaults.'.$key); | ||
$default = $default ?? config('setting.defaults.' . $key); | ||
|
||
return Arr::get($this->data, $key, $default); | ||
} | ||
|
@@ -146,7 +142,7 @@ public function all(): array | |
*/ | ||
public function flip($key): self | ||
{ | ||
return $this->set($key, ! $this->get($key)); | ||
return $this->set($key, !$this->get($key)); | ||
} | ||
|
||
/** | ||
|
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 |
---|---|---|
|
@@ -6,10 +6,6 @@ | |
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Arr; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class DatabaseSettingStore extends AbstractStore | ||
{ | ||
/** @var string */ | ||
|
@@ -120,7 +116,7 @@ public function forget($key): bool | |
{ | ||
$this->loadedData(); | ||
|
||
if (! Arr::has($this->data, $key)) { | ||
if (!Arr::has($this->data, $key)) { | ||
return false; | ||
} | ||
|
||
|
@@ -170,7 +166,7 @@ public function setExtraColumns(array $columns): self | |
*/ | ||
private function syncDeleted(array $deleted): void | ||
{ | ||
if (! empty($deleted)) { | ||
if (!empty($deleted)) { | ||
$this->model::whereIn('key', $deleted)->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 |
---|---|---|
|
@@ -7,10 +7,6 @@ | |
use InvalidArgumentException; | ||
use RuntimeException; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class JsonSettingStore extends AbstractStore | ||
{ | ||
/** | ||
|
@@ -81,7 +77,7 @@ public function forget($key): bool | |
{ | ||
$this->loadedData(); | ||
|
||
if (! Arr::has($this->data, $key)) { | ||
if (!Arr::has($this->data, $key)) { | ||
return false; | ||
} | ||
|
||
|
@@ -119,14 +115,14 @@ private function throwAnyException(): void | |
$files = $this->files; | ||
|
||
// If the file does not already exist, we will attempt to create it. | ||
if (! $files->exists($path)) { | ||
if (!$files->exists($path)) { | ||
$result = $files->put($path, '{}'); | ||
if ($result === false) { | ||
throw new InvalidArgumentException("Could not write to $path."); | ||
} | ||
} | ||
|
||
if (! $files->isWritable($path)) { | ||
if (!$files->isWritable($path)) { | ||
throw new InvalidArgumentException("$path is not writable."); | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
use Illuminate\Redis\RedisManager; | ||
use Illuminate\Support\Arr; | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
class RedisSettingStore extends AbstractStore | ||
{ | ||
/** | ||
|
@@ -64,7 +60,7 @@ public function forget($key): bool | |
{ | ||
$this->loadedData(); | ||
|
||
if (! Arr::has($this->data, $key)) { | ||
if (!Arr::has($this->data, $key)) { | ||
return false; | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* @author Michael Nabil <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
if (! function_exists('setting')) { | ||
/** | ||
* Get the setting manager instance. | ||
|