Whenever a tag is created its order_column
will be set the highest value in that column + 1
Under the hood spatie/eloquent-sortable is used, so you can use any model provided by that package. Here are some examples:
$orderedTags = Tag::ordered()->get();
Tag::setNewOrder($arrayWithTagIds);
$myModel->moveOrderUp();
$myModel->moveOrderDown();
$tag = $orderedTags->first();
$tag->moveToStart();
$tag->moveToEnd();
$tag->swapOrder($anotherTag);
Of course you can also manually change the value of the order_column
.
$tag->order_column = 10;
$tag->save();