Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function get() on null #82

Open
MazzMazz opened this issue Feb 5, 2021 · 4 comments
Open

Call to a member function get() on null #82

MazzMazz opened this issue Feb 5, 2021 · 4 comments

Comments

@MazzMazz
Copy link

MazzMazz commented Feb 5, 2021

Specs:
Laravel 7.x
Nova 3.x

Problems

When upgrading the Plugin to Version 1.1.x we get the following Exception.
We downgraded again to 1.0.11 with which everything works as expected.

{
    "message": "Call to a member function get() on null",
    "exception": "Error",
    "file": "{{pathToProject}}/vendor/dillingham/nova-attach-many/src/Http/Controllers/AttachController.php",
    "line": 46,
    "trace": [
        {
            "file": "{{pathToProject}}/vendor/dillingham/nova-attach-many/src/Http/Controllers/AttachController.php",
            "line": 30,
            "function": "getAvailableResources",
            "class": "NovaAttachMany\\Http\\Controllers\\AttachController",
            "type": "->"
        },
        {
            "file": "{{pathToProject}}/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
            "line": 54,
            "function": "edit",
            "class": "NovaAttachMany\\Http\\Controllers\\AttachController",
            "type": "->"
        },
        {
            "file": "{{pathToProject}}/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
            "line": 45,
            "function": "callAction",
            "class": "Illuminate\\Routing\\Controller",
            "type": "->"
        },

This happens in Version 1.1.1 and 1.1.0

Nova Resource Part

AttachMany::make(Tag::$singularLabel, 'tags', Tag::class)
                ->fullWidth()
                ->showPreview()
                ->height('200px')
                ->help('A Hint for the user.')
                ->showCounts()
                ->hideFromIndex(),

Eloquent Relation Part

public function tags(): BelongsToMany
    {
        return $this->belongsToMany(
            Tag::class,
            'b2b_product_tag_mapping',
            'product_id',
            'tag_id')->withTimestamps();
    }
@adamiatro
Copy link

Did you ever find a solution to this except for downgrading?

@MazzMazz
Copy link
Author

I think I'll have another look on this

Used this Plugin(1.1.1) in another Projekt (Laravel 8.26.1, Nova 3.21.0) and everything works fine.

However i just tried again (in the Projekt with the Problem) and even though the Laravel and Nova Versions are the same i get the mentioned error. The implementation in the Resource looks the same.

@dillingham
Copy link
Owner

@MazzMazz hmmm wonder why this line is returning null for you

@adamiatro
Copy link

@dillingham Please let me know if you'd rather I open a separate issue for this.

In my implementation, AttachMany works for one model (Users) but not for another in the same resource.

AttachMany::make('Users'),
BelongsToMany::make('Users'),
BelongsToMany::make('Organisations'),

This works.

AttachMany::make('Users'),
BelongsToMany::make('Users'),
AttachMany::make('Organisations'),
BelongsToMany::make('Organisations'),

This only works partially, as the Users model works fine but the next one returns null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants