|
| 1 | +--- |
| 2 | +title: Recommended |
| 3 | +weight: 2 |
| 4 | +--- |
| 5 | + |
| 6 | +While the package is very customisable, and supports a number of different approaches. The below is the recommended approach, that gives the best performance for the tables: |
| 7 | + |
| 8 | +## Installation |
| 9 | +``` |
| 10 | +composer require rappasoft/laravel-livewire-tables |
| 11 | +``` |
| 12 | + |
| 13 | +## Publish the Tables Config |
| 14 | +``` |
| 15 | +php artisan vendor:publish --tag="livewire-tables-config" |
| 16 | +``` |
| 17 | + |
| 18 | +## Livewire Tables Config Updates |
| 19 | +Update the published Livewire Tables Config (config/livewire-tables.php) and set the following to false: |
| 20 | +```php |
| 21 | + /** |
| 22 | + * Cache Rappasoft Frontend Assets |
| 23 | + */ |
| 24 | + 'cache_assets' => false, |
| 25 | + |
| 26 | + /** |
| 27 | + * Enable or Disable automatic injection of core assets |
| 28 | + */ |
| 29 | + 'inject_core_assets_enabled' => false, |
| 30 | + |
| 31 | + /** |
| 32 | + * Enable or Disable automatic injection of third-party assets |
| 33 | + */ |
| 34 | + 'inject_third_party_assets_enabled' => false, |
| 35 | + |
| 36 | + /** |
| 37 | + * Enable Blade Directives (Not required if automatically injecting or using bundler approaches) |
| 38 | + */ |
| 39 | + 'enable_blade_directives' => false, |
| 40 | +``` |
| 41 | + |
| 42 | +## Bundling the Assets |
| 43 | +As you have now told the package not to inject the assets, add the following to your resources/js/app.js file: |
| 44 | + |
| 45 | +```js |
| 46 | +import '../../vendor/rappasoft/laravel-livewire-tables/resources/imports/laravel-livewire-tables-all.js'; |
| 47 | +``` |
| 48 | + |
| 49 | +## Update Layouts |
| 50 | +Ensure that your layouts do not reference any of the following blade directives, as these are not required with the above approach |
| 51 | +``` |
| 52 | + <!-- Adds the Core Table Styles --> |
| 53 | + @rappasoftTableStyles |
| 54 | + |
| 55 | + <!-- Adds any relevant Third-Party Styles (Used for DateRangeFilter (Flatpickr) and NumberRangeFilter) --> |
| 56 | + @rappasoftTableThirdPartyStyles |
| 57 | +
|
| 58 | + <!-- Adds the Core Table Scripts --> |
| 59 | + @rappasoftTableScripts |
| 60 | +
|
| 61 | + <!-- Adds any relevant Third-Party Scripts (e.g. Flatpickr) --> |
| 62 | + @rappasoftTableThirdPartyScripts |
| 63 | +``` |
| 64 | + |
| 65 | +## Tailwind Specific |
| 66 | +If using Tailwind, you should update your tailwind.config.js file, adding the following to the "content" section under module.exports. This ensures that the Livewire Tables specific core classes are included. |
| 67 | + |
| 68 | +```js |
| 69 | + './vendor/rappasoft/laravel-livewire-tables/resources/views/*.blade.php', |
| 70 | + './vendor/rappasoft/laravel-livewire-tables/resources/views/**/*.blade.php', |
| 71 | +``` |
| 72 | + |
| 73 | +It is also recommended to add the paths to any Livewire Tables components, for example: |
| 74 | +```js |
| 75 | + './app/Livewire/*.php', |
| 76 | + './app/Livewire/**/*.php', |
| 77 | +``` |
| 78 | +So that any classes used in setTdAttributes or similar are included! |
| 79 | + |
| 80 | +## Run your build process |
| 81 | +``` |
| 82 | +npm run build |
| 83 | +``` |
| 84 | + |
| 85 | +## Clear Cached Views |
| 86 | +``` |
| 87 | +php artisan view:clear |
| 88 | +``` |
| 89 | + |
| 90 | +You may of course run view:cache at this point. |
0 commit comments