Skip to content

Commit

Permalink
feat: Add getOrder method with dynamic column support.
Browse files Browse the repository at this point in the history
- Implemented `getOrder()` method to fetch order value from a dynamically determined column, enhancing flexibility in model configuration.
- Added tests to validate the `getOrder()` functionality.
- Updated PHPDoc for `getOrder()` to clearly explain the method's behavior and its dynamic column determination.

This update ensures that the model can handle varying order columns, catering to different sorting configurations seamlessly.
  • Loading branch information
YazeedAlsaif committed Jun 1, 2024
1 parent 6b16af6 commit 813eddc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/SortableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,29 +430,26 @@ public function it_can_tell_if_element_is_last_in_order()
public function it_can_determine_custom_column_and_get_order_number()
{
$model = Dummy::first();

$this->assertEquals($model->getOrder(), 1);



$model = new class () extends Dummy {
public $sortable = [
'order_column_name' => 'my_custom_order_column',
];
};

$this->assertEquals($model->determineOrderColumnName(), 'my_custom_order_column');

$model->my_custom_order_column = 2;

$this->assertEquals($model->getOrder(), 2);



$model = new class () extends Dummy {
public $sortable = [
'order_column_name' => 'my_other_custom_order_column',
];
};

$model->my_other_custom_order_column = 3;

$this->assertEquals($model->getOrder(), 3);
}
}

0 comments on commit 813eddc

Please sign in to comment.