| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Livewire;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Collection;
- use Illuminate\Support\Facades\App;
- use Illuminate\Support\Facades\DB;
- use Livewire\Component;
- class ShowReports extends Component
- {
- public $datatableName;
- public $datatableColumnsConfig;
- public $datatableHeadersConfig;
- public $datatableButtonsConfig;
- public $datatableColumnDefsConfig;
- public function mount($datatableName)
- {
- // Receive the dynamic datatable name during initialization
- $this->datatableName = $datatableName;
- // Fetch the DataTable configuration
- $datatableConfigQuery = DB::table('datatables')->where('name', $datatableName)->first();
- if (!$datatableConfigQuery) {
- abort(404, 'DataTable configuration not found');
- }
- // Store the decoded JSON as a plain array
- $this->datatableColumnsConfig = json_decode($datatableConfigQuery->columns_config, true);
- $this->datatableHeadersConfig = json_decode($datatableConfigQuery->column_headers, true);
- $this->datatableColumnDefsConfig = json_decode($datatableConfigQuery->column_defs, true);
- $this->datatableButtonsConfig = json_decode($datatableConfigQuery->buttons, true);
- }
- public function render()
- {
- return view('livewire.show-reports')->layout('components.layouts.datatables');
- }
- }
|