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

Add Button::make()->attach('User') navigation #12

Closed
dillingham opened this issue Feb 4, 2019 · 4 comments
Closed

Add Button::make()->attach('User') navigation #12

dillingham opened this issue Feb 4, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@dillingham
Copy link
Owner

It would be handy to add attach() like create and edit etc

@dillingham dillingham added the enhancement New feature or request label Feb 4, 2019
@dillingham dillingham self-assigned this Feb 4, 2019
@dillingham dillingham changed the title Add ->attach() navigation Add Button::make()->attach('User') navigation Feb 4, 2019
@knutle
Copy link

knutle commented Feb 22, 2019

I see you already have a branch going for this, but just thought I'd add this in case it is useful.

I needed this functionality, so implemented a quick fix.

public function editAttached($namespace, $id, $relationNamespace, $relationId, $viaRelationship)
    {
        $this->route('edit-attached', [
            'resourceName' => $this->normalizeResourceName($namespace),
            'resourceId' => $id,
            'relatedResourceName' => $this->normalizeResourceName($relationNamespace),
            'relatedResourceId' => $relationId,
        ], [
            'viaRelationship' => $viaRelationship
        ]);

        return $this;
    }
Button::make('Text')->editAttached(
                    MainClass::class, $this->main_class_id,
                    RelationClass::class, $this->relation_class_id,
                    'relationMethod'
                )
public function route($name, $params, $query = [])
    {
        $this->type = 'route';

        $this->route = [
            'name' => $name,
            'params' => $params,
            'query' => $query,
        ];

        return $this;
    }

@dillingham
Copy link
Owner Author

@klepak ah thanks! Yeah I was trying to work it out so the resource the field was within was already associated and we only would declare the relation. But I also like the fact that your approach can be used anywhere.

@knutle
Copy link

knutle commented Feb 22, 2019

@dillingham I think both approaches are valuable. In my case I wanted to add a link to edit the relationship between resource B and C from the details page of resource A. Depends on how customizable you need it I guess. Maybe try to auto-detect if no explicit parameters are provided?

@4unkur
Copy link

4unkur commented Jul 17, 2019

Would be fine at least have a possibility to pass query string:

    public function route($name, $params, $query = [])
    {
        $this->type = 'route';

        $this->route = [
            'name' => $name,
            'params' => $params,
            'query' => $query,
        ];

        return $this;
    }

Currently it's impossible to pass query params...

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

No branches or pull requests

3 participants