Fields

MorphToMany

Extends BelongsToMany

  • has the same features

MorphToMany relationship field in Laravel

Same as MoonShine\Fields\Relationships\BelongsToMany only for MorphToMany relationships MoonShine\Fields\Relationships\MorphToMany.

To create this field, use the static make() method.

MorphToMany::make( Closure|string $label, ?string $relationName = null, Closure|string|null $formatted = null )
MorphToMany::make(
Closure|string $label,
?string $relationName = null,
Closure|string|null $formatted = null
)
  • label - label, field header
  • relationName - name of the relationship
  • formatted - a closure or field in a related table to display values.
use MoonShine\Fields\Relationships\MorphToMany; //... public function fields(): array { return [ MorphToMany::make('Categories', 'categories') ]; } //...
use MoonShine\Fields\Relationships\MorphToMany;
 
//...
 
public function fields(): array
{
return [
MorphToMany::make('Categories', 'categories')
];
}
 
//...