Skip to content

How to attach relation with pivot value? #141

@PitchRE

Description

@PitchRE

How I can add pivot values to attach action?

public function attachCollectionItems(
        UserSchema $schema,
        UserRequest $request,
        User $user
    ) {

        $collectionItems = $schema
            ->repository()
            ->modifyToMany($user, 'collection-items')
            ->attach($request->validatedForRelation(), ['status' => 1]);
    }

The problem is that attach() is not native laravel method. I cannot add pivot values there.
Is there a way to to do that using that package or i'll have to write this method myself completely?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions