Skip to content

Commit

Permalink
adding save and get filter section for page datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
perladarianny15 committed Feb 1, 2022
1 parent b51b896 commit 7513939
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Http/Livewire/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function mount($tableArr = null, $query = null, $filter = null)
$this->getFilterSortFromSession();
$this->tableStruct();
$this->getFilterFromSession();
$this->getFilterPageFromSession();
}

public function tableStruct()
Expand Down Expand Up @@ -102,6 +103,7 @@ public function tableStruct()
public function Pagination($page)
{
$this->perPage = $page;
$this->saveFilterPageToSession();
}

public function sortBy($field)
Expand Down Expand Up @@ -172,6 +174,15 @@ public function getFilterSortFromSession()
$this->sortDirection = Session::get('sort_d' . $this->tableArr['key'], '');
}

public function saveFilterPageToSession()
{
Session::put('page_' . $this->tableArr['key'], $this->perPage);
}

public function getFilterPageFromSession()
{
$this->perPage = Session::get('page_' . $this->tableArr['key'], 30);
}

protected function buildQuery()
{
Expand Down

0 comments on commit 7513939

Please sign in to comment.