-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Add make:table command #408
Conversation
This is great idea. |
The maintainer requested this as the command. It doesn't conflict with anything else. #399 (comment) |
Probably a valid point though I can't imagine people installing two table plugins in one project? |
A really simple upgrade to this would be to pass in an optional parameter for the model you are working with, and have that prepopulate in the For example, public function query(): Builder
{
return User::query(); // this line here
} It could be simplified even more by just accepting the model name as the second parameter, so
Happy to add this if you like. |
Okay, I added the model as a second parameter (optional). Now you can do this: scaffold without the model scaffold with User model I built the logic to be smart enough to import the model class as long as the model is either in the app folder or in the app/models folder. If it's somewhere else, then I show an error in the console and just import the non-existent app/models file. |
Awesome good work. I'll try to get this in this week I've just been swamped. |
I added one more feature. If you pass in <x-livewire-tables::table.cell>
{{-- Note: This is a tailwind cell --}}
{{-- For bootstrap 4, use <x-livewire-tables::bs4.table.cell> --}}
{{-- For bootstrap 5, use <x-livewire-tables::bs5.table.cell> --}}
</x-livewire-tables::table.cell> and it will also add the row view method to the class: public function rowView(): string
{
return 'livewire-tables/rows/snake_of_classname.blade.php';
} |
Sorry for all the commits. I'm just now getting into some good testing and I'm finding issues. I think I have worked everything out now. Feel free to squash commits. |
yes, it will become confusing on large projects |
Just checking in here. Anything else you'd like me to consider adding or anything I can explain? |
Sorry I've been swamped. I'm looking at it now (though its 1am here) and will probably finish looking tomorrow. I'm going to change it to I'll make a release even if this is the only thing just so people can use it. |
I've added the
make:table
command. You just pass a class name and it scaffolds out a stub that helps you get started.Hopefully this is pretty self explanatory. I used a lot of the code and approach as the Livewire make command.
Sorry I don't have any tests.