Open lovecoding-git opened 4 years ago
<?php
namespace Kdion4891\LaravelLivewireTables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Str;
use Kdion4891\LaravelLivewireTables\Traits\ThanksYajra;
use Livewire\Component;
use Livewire\WithPagination;
class TableComponent extends Component
{
use WithPagination, ThanksYajra;
public $table_class;
public $thead_class;
public $header_view;
public $footer_view;
public $search;
public $checkbox;
public $checkbox_side;
public $checkbox_attribute = 'id';
public $checkbox_all = false;
public $checkbox_values = [];
public $sort_attribute = 'id';
public $sort_direction = 'desc';
public $per_page;
public function mount($type=null)
{
$this->setTableProperties();
}
I added $type field and it worked well. :)
You don't need to touch the original class. You can override the mount method with optional parameters (id is obligatory) Example:
public function mount($id=null,$institucion=false){
if ($institucion!==false )
$this->filterinstitucion = $institucion->id;
$this->setTableProperties();
}
I want to pass variable to livewire component.
@livewire('livewire-component', ['type'=>'A'])
public function mount($type) { $this->setTableProperties(); $this->type = $type; }
It displayed error.Declaration of App\Http\Livewire\LivewireComponent::mount($type) should be compatible with Kdion4891\LaravelLivewireTables\TableComponent::mount() (View: ~\resources\views\app\tabl.blade.php)
Thanks