thedevdojo/voyager

[BUG] belongsToMany Relationship, Allow Tagging, and Custom URL Slugs

Open

#4128 opened on May 9, 2019

View on GitHub
 (1 comment) (4 reactions) (0 assignees)PHP (11,817 stars) (2,652 forks)batch import
help wantedtype:bug

Description

Version information

  • Laravel: v5.7.28
  • Voyager: v1.2.3
  • PHP: 7.2
  • Database: MySQL 5.7.25

Description:

When a relationship has tagging enabled and the BREAD for the other table has a custom slug a route not defined error is thrown.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create belongsToMany relationships
  2. Create BREAD with custom "URL Slugs"
  3. Add relationship and Allow Tagging
  4. Go to the Add or Edit page of the BREAD with the relationship

Expected behavior

The add and edit page to load.

Additional context

vendor/tcg/voyager/resources/views/formfields/relationship.blade.php:159

When I looked at the relationship blade file the route is created off the table name when tagging is on. And the route for the relationship is a custom slug.

@if(isset($options->taggable) && $options->taggable == 'on')
    data-route="{{ route('voyager.'.\Illuminate\Support\Str::slug($options->table).'.store') }}"
    data-label="{{$options->label}}"
    data-error-message="{{__('voyager::bread.error_tagging')}}"
@endif

Contributor guide