Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
#9  #8 #7 #6  Fixed
  • Loading branch information
lahirulhr committed Jun 19, 2024
1 parent c87fe34 commit 6c961ea
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
29 changes: 25 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
</p> -->


# ⚙ Nova Settings

Settings management UI for Laravel Nova™ dashboard using **Native fields**


![screenshot1](./sc1.png)

<br>
Expand All @@ -19,6 +17,7 @@ Settings management UI for Laravel Nova™ dashboard using **Native fields**
```bash
composer require visanduma/nova-settings
```

<br>

### 💠 Configuration
Expand Down Expand Up @@ -60,15 +59,30 @@ class User extends Authenticatable
}

```

Register tool in Nova Service Provider

```php
public function tools()
{
return [
\\other tools
\Visanduma\NovaSettings\NovaSettings::make(),

];
}

```

<br>

### 💠 Create your first setting class

You can use `nova-settings:create` command to build a fresh settings class
You can use `nova-settings:make` command to build a fresh settings class

```
php artisan nova-settings:create Contact
php artisan nova-settings:make Contact
```

Expand Down Expand Up @@ -115,6 +129,7 @@ class Contact extends NovaSettingsMum
}

```

<br>

### 💠 Registering settings
Expand All @@ -134,6 +149,7 @@ public function boot()
]);
}
```

<br>

### 💠 Customizing the settings class
Expand Down Expand Up @@ -167,6 +183,7 @@ Customizing uriKey. `uriKey` is used when saving/retrieving the settings
return 'user-contacts';
}
```

<br>

### 💠 User settings vs Global settings
Expand All @@ -179,6 +196,7 @@ You can easily configure the settings type with `global` property in the setting
```php
protected bool $global = false;
```

<br>

### 💠 Retrieving the settings
Expand All @@ -204,6 +222,7 @@ NovaSettings::global('system');

nova_settings_global('system.phone'),
```

<br>

### 💠 Transforming inputs
Expand All @@ -219,6 +238,7 @@ protected function transformInputs(array $inputs): array
return $inputs;
}
```

<br>

### 💠 Hooks
Expand All @@ -230,6 +250,7 @@ protected function afterSaved(NovaRequest $request)
// this method will be called after the form is saved
}
```

<br>

### Known issues
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateSettings extends Command
*
* @var string
*/
protected $signature = 'nova-settings:create {name}';
protected $signature = 'nova-settings:make {name}';

/**
* The console command description.
Expand Down
10 changes: 8 additions & 2 deletions src/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Visanduma\NovaSettings\Http\Controllers;

use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Storage;
use Laravel\Nova\Fields\Field;
use Laravel\Nova\Fields\FieldCollection;
Expand Down Expand Up @@ -118,8 +119,13 @@ private function panelJsonSerializeWithFields(Panel $panel, $values)
private function resolvePanel(Panel $panel, $values)
{
return collect($panel->data)
->each(function ($field) use ($values) {
$field->resolve($this->makeFakeResource($field->attribute, $values[$field->attribute] ?? ''));
->each(function (Field $field) use ($values) {
$value = $values[$field->attribute] ?? '';

if ($field->component == 'date-field') {
$value = Date::parse($value);
}
$field->resolve($this->makeFakeResource($field->attribute, $value));
})
->toArray();
}
Expand Down
5 changes: 5 additions & 0 deletions src/NovaSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Laravel\Nova\Menu\MenuSection;
use Laravel\Nova\Nova;
Expand Down Expand Up @@ -50,6 +51,10 @@ public static function autoRegister()

$directory = config('nova-settings.settings_path');

if (! File::exists($directory)) {
return;
}

$resources = [];

foreach ((new Finder())->in($directory)->files() as $resource) {
Expand Down

0 comments on commit 6c961ea

Please sign in to comment.