InfyOmLabs / adminlte-generator

Boilerplate of Laravel with InfyOm Laravel Generator for AdminLTE Templates
https://infyom.com/open-source/laravelgenerator/docs/8.0/boilerplates
388 stars 273 forks source link

Datatables not displaying data #87

Closed abid1208 closed 2 years ago

abid1208 commented 3 years ago

PROBLEM I was facing this issue where the datatables view was not displaying any data and was not showing any errors. The table was being shown but it was empty, despite there being data in the database. Rest of the views for creating and editing were working fine. I used php artisan infyom:api_scaffold $Model command with datatables true being set in the config.

ATTEMPTS TO SOLVE I followed the blog, tutorials, past github issues and video tutorials but I could not get the datatables to display data. I even tried different Laravel and AdminLTE-generator versions with the same result.

CULPRIT After inspecting the final php file within browser, I noticed that the javascript for datatables was not being imported. The reason is the table file being created by infyom uses @push('third_party_scripts') to include dataTable related JS; while in the main app layout in layout/app.blade.php, 'third_party_scripts' is initialized as @yield. @push in Laravel can be used with @stack.

SOLUTION Find @yield('third_party_scripts') in views/layouts/app and change it to @stack('third_party_scripts'). Datatables should now work.

I have submitted the relevant changes in the adminlte-templates

stefanrakicfaxi commented 2 years ago

I have the same issue and solve it in the same way. The next problem is missing icons in data tables and missing padding it's looks very bad for now

tarunhere commented 2 years ago

That's correct. We need to use stack and I am also searching to fix icons. Let me know if anyone found solution to it. Thanks

ShaileshInfyom commented 2 years ago

fix in PR #90

kodux-dev commented 2 years ago

I have the same issue but didn't achieve to fix it... Checking the views/layouts/app file and @stack('third_party_scripts') is well there! No errors in browser. But no data returned ??? dd() my variable give me an empty Database Eloquent Collection when database well populated with data! Help me please...

kodux-dev commented 2 years ago

I've find why my data doesn't show , when i update my data, the SoftDelete trait set a "deleted_at" into my DB wich i find it really strange because it's an update and not a deletion!? Any help or documentation about why Laravel softdelete data on update??? (find nothing on my google friend )