outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
271 stars 98 forks source link

Support fix for ebess/advanced-nova-media-library #129

Open bendadaniel opened 1 year ago

bendadaniel commented 1 year ago

Did someone find way to make it works with package ebess/advanced-nova-media-library?

https://github.com/ebess/advanced-nova-media-library

Thank you Daniel

KasparRosin commented 1 year ago

Pull requests are welcome. 🥳

yiukamsum commented 1 year ago

Here is my workaround.

I have no idea how to apply this workaround to this plugin. Any pull requests based on this workaround are welcome.

  1. Creat a FakeModel wich has implements HasMedia and use InteractsWithMedia
    • code example (app/FakeModel.php)
      
      <?php

namespace App;

use Illuminate\Database\Eloquent\Model; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; use Ebess\AdvancedNovaMediaLibrary\Fields\Media;

class Setting extends FakeModel implements HasMedia { use InteractsWithMedia;

public function __construct($key, $value)
{
    $this->{$key} = $value;
}
//

}


2. change the `makeFakeResource` functiom
- code example (vendor_custom/nova-settings/src/Http/Controllers/SettingsController.php)
```php
<?php

namespace OptimistDigital\NovaSettings\Http\Controllers;
.
.
.
use App\FakeModel;
.
.
.
class SettingsController extends Controller
{
    protected function makeFakeResource(string $fieldName, $fieldValue)
    {
        return new Setting($fieldName, $fieldValue);
    }
}
hayatbiralem commented 1 year ago

I decided to drop outl1ne/nova-settings from my stack and used whitecube/nova-flexible-content to store my settings in an aditional resource named Setting and then I created a custom Nova menu which contains a menu item for the edit view of the very first setting instance. It works like a charm so far.