Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to create a listing from a list of items and specifying a callback to find the order of the items #9

Closed
khalyomede opened this issue Jan 13, 2023 · 0 comments · Fixed by #14
Assignees
Labels
enhancement New feature or request

Comments

@khalyomede
Copy link
Owner

khalyomede commented Jan 13, 2023

For example instead of this:

use Khalyomede\ReorderBeforeAfter\Listing;
use App\Models\Product;

$items = Product::all()->map(fn (Product $product): Item => new Item($product, $product->order));
$listing = Listing::from($items);

We could have this, which is reducing the redunduncy if the list of objects comes from a previous call:

use Khalyomede\ReorderBeforeAfter\Listing;
use App\Models\Product;

$listing = Listing::outOf(Product::all(), fn (Product $product): Item => new Item($product, $product->order);
@khalyomede khalyomede added the enhancement New feature or request label Jan 13, 2023
@khalyomede khalyomede self-assigned this Jan 13, 2023
khalyomede added a commit that referenced this issue Jan 14, 2023
…lback to get the order from the array values
khalyomede added a commit that referenced this issue Jan 14, 2023
…lback to get the order from the array values (#14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant