ShowReports.php 1007 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Livewire;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Support\Collection;
  5. use Illuminate\Support\Facades\App;
  6. use Illuminate\Support\Facades\DB;
  7. use Livewire\Component;
  8. class ShowReports extends Component
  9. {
  10. public $datatableName;
  11. public $datatableColumnsConfig;
  12. public function mount($datatableName)
  13. {
  14. // Receive the dynamic datatable name during initialization
  15. $this->datatableName = $datatableName;
  16. // Fetch the DataTable configuration
  17. $datatableConfigQuery = DB::table('datatables')->where('name', $datatableName)->first();
  18. if (!$datatableConfigQuery) {
  19. abort(404, 'DataTable configuration not found');
  20. }
  21. // Store the decoded JSON as a plain array
  22. $this->datatableColumnsConfig = json_decode($datatableConfigQuery->columns_config, true);
  23. }
  24. public function render()
  25. {
  26. return view('livewire.show-reports')->layout('components.layouts.datatables');
  27. }
  28. }