filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
19.3k stars 2.96k forks source link

Call to a member function getAttributeValue() on null Using Spatie Media & Translatable #7921

Closed PterodactylStore closed 1 year ago

PterodactylStore commented 1 year ago

Package

filament/spatie-laravel-media-library-plugin

Package Version

v3.0.27

Laravel Version

v10.18.0

Livewire Version

v3.0.0-beta.9

PHP Version

PHP 8.2.8

Problem description

https://github.com/filamentphp/filament/assets/133764150/9cdef2b9-1fc4-4a6d-ac67-114b2875c76b

Expected behavior

i have try it without Spatie Translatable Plugin and works good

but when i have enabled Translatable in PostResource im getting the error

Steps to reproduce

try yo upload image in Post Resource with Translatable plugin added to PostResource

Reproduction repository

https://github.com/PterodactylStore/filament-test

Relevant log output

Call to a member function getAttributeValue() on null
pieinn commented 1 year ago

Same - Call to a member function getAttributeValue() on null

awcodes commented 1 year ago

Closing this as it's a duplicate of #7591

Ihabafia commented 10 months ago

first in the model you have to have the $translatable as

protected array $translatable = ['title', 'slug', 'description'];

also your migration must have all these fields as json:

        Schema::create('porst', function (Blueprint $table) {
            $table->id();
            $table->json('title');
            $table->json('slug');
            $table->json('description');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->useCurrentOnUpdate();
        });

Finally make sure that you have the use HasTranslations; in the Post Model Class

I think this should solve the issue for you. I hope that this information helps.