#Code review

10 messages · Page 1 of 1 (latest)

analog obsidian
#

Hi everyone, I haven't been doing laravel for that long and was wondering what the other options would be here to populate the datatable and submit a form, this is some code I found in the old codebase so don't flame me. It's using KeenThemes Laravel and JQuery with datatables. Open for any suggestions
https://gist.github.com/dukesteen/900e6db3a614b739a98ac087320e815a

#

One option could definitely be to use LiveWire

#

I'm also wondering what I could do to reduce the amount of queries that are executed upon the loading of the portal_settings.blade.php view, there is another view for system settings that executes 280 queries on load

#

Which isn't optimal

analog obsidian
#

Nobody?

ashen garnet
# analog obsidian Nobody?

Please be patient. You’re asking people to do a code review of a load of code they’ve not written, for free. It’s not even been 24 hours.

analog obsidian
#

Sorry

ashen garnet
#

I’ve only had a quick glance at the code in the Gist, but the key to any re-factoring is to do small changes and test. Re-factor a small part and test; if everything is still OK then do a little bit more and test.

#

Unfortunately I’m not familiar with this “KeenThemes” but a lot of themes tend to bloated with code like this. So you’ll just have to evaluate the code and see if things can be re-factored in a piecemeal fashion, or if the theme isn’t flexible and will just break if you start moving or changing the smallest piece of code.

#

As for queries, you’ll need to use something like laravel-debugbar or Telescope to see where they’re originating from. If you’re getting so many queries on the loading of a page, then that may be stemming from N+1 problems and can be fixed by eager-loading whatever relations are called when looping.