nova-settings icon indicating copy to clipboard operation
nova-settings copied to clipboard

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

Open bendadaniel opened this issue 2 years ago • 3 comments

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

bendadaniel avatar Jul 31 '22 21:07 bendadaniel

Pull requests are welcome. 🥳

KasparRosin avatar Oct 21 '22 14:10 KasparRosin

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;
    }
    //
}
  1. change the makeFakeResource functiom
  • code example (vendor_custom/nova-settings/src/Http/Controllers/SettingsController.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);
    }
}

yiukamsum avatar Nov 07 '22 09:11 yiukamsum

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.

hayatbiralem avatar Jan 28 '23 15:01 hayatbiralem