A good learning resource is here.:
Question about sort dropdown for sorting recipes by date in Livewire
Hey everyone
This question is theoretical, I just wanna to gain some approaches to achieving this task
How does my code/views look in the project:
I have a filter that shows me a page with list of filtered recipes:
RecipeController
class RecipeController extends Controller
{
public function index(RecipeFilterRequest $request)
{
// ...filtration logic => $recipes
return view('recipes.recipes', compact('recipes'));
}
recipes.blade.php:
@foreach($recipes as $recipe)
<x-recipe-card :recipe="$recipe"/>
@endforeach
What I want to achieve:
I need to create a logic for dropdown filter that will sort list of filtered recipes by date added
It looks like this: https://i.ibb.co/wrrffZVK/sort-dropdown.jpg
Has anyone done anything similar/exactly the same?
Would be grateful for some advices
EDIT 01:
Here's my suggestion:
Make an extra livewire component livewire/recipes-list.blade.php with a class RecipesList.php
and I'll basically do everything in this order:
RecipeController =(passing $recipes)=> recipes.blade.php =(passing to livewire component $recipes)=> livewire/recipes-list.blade.php
and in livewire/recipes-list.blade.php I'll add logic for this dropdown
What do you think?
Please or to participate in this conversation.