Skip to content

Sort values not generated on MorphPivot table #139

@kuchienkz

Description

@kuchienkz

I'm trying to use this package on a MorphPivot model, but it's not working, no errors while debugging, it just does not generate the sort/order values. Am I missing something?

Here is the model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\MorphPivot;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class Groupables extends MorphPivot implements Sortable
{
    use SortableTrait;

    public $sortable = [
        'order_column_name' => 'sort',
        'sort_when_creating' => true,
    ];

    public function buildSortQuery()
    {
        return static::query()
        ->where('group_id', $this->group_id)
        ->where('groupable_type', $this->groupable_type);
    }
}

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