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

[Bug]: in belongsToMany i have problem , doesn't show groups #120

Closed
wisedev99 opened this issue Aug 14, 2024 · 4 comments
Closed

[Bug]: in belongsToMany i have problem , doesn't show groups #120

wisedev99 opened this issue Aug 14, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@wisedev99
Copy link

What happened?

Validation: you should pass an array as a value! !i && !Array.isArray(n) && console.error("Validation: you should pass an array as a value!"),

Screenshot 2024-08-14 at 12 04 35

Screenshot 2024-08-14 at 13 07 29

How to reproduce the bug

 SelectTree::make('groups')
          ->relationship('groups', 'name',  'parent_id')
Screenshot 2024-08-14 at 12 02 14

in course model public function groups(): BelongsToMany
{
return $this->belongsToMany(Group::class);
}
in group model public function courses(): BelongsToMany
{
return $this->belongsToMany(Course::class);
}

Package Version

3.1

PHP Version

8.3

Laravel Version

11

Which operating systems does with happen with?

No response

Notes

No response

@wisedev99 wisedev99 added the bug Something isn't working label Aug 14, 2024
@CodeWithDennis
Copy link
Owner

Since you closed it, i assume you figured it out? @wisedev99

@DevYSM
Copy link

DevYSM commented Nov 4, 2024

I have the same issue

Validation: you should pass an array as a value!

@dharen008
Copy link

dharen008 commented Dec 18, 2024

Anyone solve this? i got the same issue. anyone help please? @CodeWithDennis

SelectTree::make( 'teams' )
->relationship( 'teams', 'name', 'department_id' )

Model with belongsToMany Pivot model TeamUser
public function teams()
{
return $this->belongsToMany( Team::class )
->using( TeamUser::class );
}

Database Table team_user structure
image

@mpskovvang
Copy link

I had the same issue. I solved it by passing an empty array to the default state:

SelectTree::make('categories')->default([])

I'm using the component in a create-only resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants