outl1ne / nova-settings

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

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

Open bendadaniel opened 2 years ago

bendadaniel commented 2 years 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 2 years ago

Pull requests are welcome. 🥳

yiukamsum commented 2 years 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.