statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 72 forks source link

Using eloquent driver for global_set_variables is not working as expected #213

Closed aknEvrnky closed 5 months ago

aknEvrnky commented 9 months ago

Hi,

My hibrit config for global_sets and global_set_variables is just like below:

    'blueprints' => [
        'driver'          => 'file',
        'blueprint_model' => \Statamic\Eloquent\Fields\BlueprintModel::class,
        'fieldset_model'  => \Statamic\Eloquent\Fields\FieldsetModel::class,
    ],

    // .... some more configs

    'global_sets' => [
        'driver' => 'file',
        'model'  => \Statamic\Eloquent\Globals\GlobalSetModel::class,
    ],

    'global_set_variables' => [
        'driver' => 'eloquent',
        'model'  => \Statamic\Eloquent\Globals\VariablesModel::class,
    ],

When I create a new global set, its blueprint is being created under resources/blueprints/globals as expected. But actual global is not saved anywhere.

It also creates a content file under content/globals with the title attribute. When I add some data to my global, it adds the data to both the global_set_variables table in the database and the content/globals/my_global_file.yaml file as a data attribute.

Data variables are only retrieved from the content/globals/my_global_file.yaml file which is not as expected.

ryanmitchell commented 9 months ago

Can you copy the result of php please support:details here?

aknEvrnky commented 9 months ago

Environment Application Name: hidden for privacy Laravel Version: 10.28.0 PHP Version: 8.2.7 Composer Version: 2.5.8 Environment: local Debug Mode: ENABLED URL: localhost:8000 Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: log Cache: statamic Database: mysql Logs: daily Mail: log Queue: sync Session: database

Filament Packages: filament, forms, notifications, support, tables Version: v3.0.78 Views: NOT PUBLISHED

Livewire Livewire: v3.0.8

Statamic Addons: 2 Antlers: runtime Stache Watcher: Enabled Static Caching: Disabled Version: 4.28.0 Solo

Statamic Addons statamic/eloquent-driver: 2.8.0 withcandour/aardvark-seo: 3.0.0

Statamic Eloquent Driver Asset Containers: file Assets: eloquent Blueprints: file Collection Trees: eloquent Collections: file Entries: eloquent Forms: eloquent Global Sets: file Global Variables: eloquent Navigation Trees: file Navigations: file Revisions: eloquent Taxonomies: file Terms: eloquent

ryanmitchell commented 9 months ago

In single site mode (ie not multi-site) the data does still save to the YAML file. This may be something thats updated in a future Statamic core version, but it's not something thats possible to change right now without breaking existing setups.

However, I'm not seeing the data issue you are experiencing - for me in the same setup, the database data takes preference.

ryanmitchell commented 5 months ago

Going to close this due to inactivity.