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

Allows using dot notation in query string #4913

Closed
wants to merge 2 commits into from
Closed

Allows using dot notation in query string #4913

wants to merge 2 commits into from

Conversation

luanfreitasdev
Copy link
Contributor

Review the contribution guide first at: https://laravel-livewire.com/docs/2.x/contribution-guide

1️⃣ Is this something that is wanted/needed? Did you create a discussion about it first?
#2036
2️⃣ Did you create a branch for your fix/feature? (Master branch PR's will be closed)
Yes
3️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
No
4️⃣ Does it include tests? (Required)
Yes
5️⃣ Please include a thorough description (including small code snippets if possible) of the improvement and reasons why it's useful.

Be able to interpret the queryString using dot notation

Necessity
→ We have an array called $filters and it has all the information that will be used for filtering in the database later in a dynamic livewire component

Note
→ Must be used together with an alias to not break the url (dot notation only).

To add this possibility I used the data_get and data_set functions to manipulate the class data.

public $filters = [
	'input_text' => [
	     'dishes' => [
		'name' => 'Pastel de Nata',
	     ]
	]
];

public function getQueryString(): array
{
    return [
	'search' => ['except' => 1],
        'page' => ['except' => 1],
        'filters.input_text.dishes.name' => ['as' => 'name', 'except' => ''], // <- fix this
    ];
}

Thanks for contributing! 🙌

@joshhanley
Copy link
Member

While we're developing V3, we're trying to keep V2 stable and limit API changes/additions. In that spirit, PR's like this that may otherwise make sense to merge, we're unfortunately closing. Thank for your effort and input!

@joshhanley joshhanley closed this Nov 17, 2022
@livelogic
Copy link

I'm puzzled about this answer. The queryString concept is great, and having it short of dot notation makes it much weaker, because array props are also a great pattern.

We're left with either singleton props as queryString members, or otherwise whole arrays. Opting for whole arrays much betrays the healthy purpose of cleaning up URLs.

I wish this could be reconsidered a priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants