laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.93k stars 809 forks source link

More flexible Livewire components #1507

Closed fabiomlferreira closed 1 week ago

fabiomlferreira commented 2 weeks ago

I think Jetstream (Livewire version) has a significant limitation in most of its components, as it always uses the current user. This limitation prevents us from reusing the Livewire components for administrative purposes. In many applications, there is an admin who can view and edit every user on the platform. An admin should be able to edit user details, change user passwords (without requiring the current password), and delete users. These are basic functions for an Administrator.

In the current version of Jetstream, we need to duplicate code and make several changes because the existing Livewire components always reference "Auth::user()".

A better approach would be to add an optional attribute to each Livewire component to specify the user being edited. If not provided, it should default to "Auth::user()". This way, the code will remain backward compatible.

What do you think?

driesvints commented 1 week ago

Heya. I think this is a bit beyond what Jetstream offers and that you're better off building this yourself. Jetstream caters to the 90% use case which yours clearly falls outside off. Sorry

fabiomlferreira commented 1 week ago

@driesvints interesting, so in 90% use cases the platforms don't have an admin user that can edit/delete users on the platform?

In all my projects and my client projects the administrator can edit the regular users. In your projects how do you handle that? You don't have a admin role?

driesvints commented 1 week ago

@fabiomlferreira they do but that's usually done through a backend like Nova.

fabiomlferreira commented 1 week ago

I bet most Laravel developers not use Nova, I know that Laravel want to make money, but I think that a starter kit like Jetstream should be enough to create a basic platform with an admin area. But it's up to you, at the moment I'm creating my own view and controllers but it's like duplicated work that jetstream could easily fix.

driesvints commented 1 week ago

@fabiomlferreira you could always attempt a PR to see if Taylor would accept 👍