1
0
Fork 0

app/Http/Livewire/Datatable.php: Reorder methods.

This commit is contained in:
Henrik Hautakoski 2022-01-24 23:06:13 +01:00
parent b012f2b6bc
commit 89755f975f

View file

@ -93,6 +93,38 @@ class Datatable extends Component
return class_basename($this->model); return class_basename($this->model);
} }
/**
* Set trashed flag.
*/
public function setTrashed($value)
{
$this->trashed = (bool) $value;
if ($this->trashed) {
// Add deleted_at columns.
$this->columns['deleted_at'] = 'Deleted at';
$this->sort_columns['deleted_at'] = 'deleted_at';
} else {
// Unset deleted_at columns.
unset($this->columns['deleted_at']);
unset($this->sort_columns['deleted_at']);
// if delete_at was the sorting column
// revert back to default sorting.
if ($this->sort == 'deleted_at') {
$this->sort = $this->default_sort;
}
}
}
/**
* Toggle trashed flag
*/
public function toggleTrashed()
{
$this->setTrashed(!$this->trashed);
}
/** /**
* Delete an record * Delete an record
*/ */
@ -164,36 +196,4 @@ class Datatable extends Component
return view('livewire.datatable', ['items' => $items]); return view('livewire.datatable', ['items' => $items]);
} }
/**
* Toggle trashed flag
*/
public function toggleTrashed()
{
$this->setTrashed(!$this->trashed);
}
/**
* Set trashed flag.
*/
public function setTrashed($value)
{
$this->trashed = (bool) $value;
if ($this->trashed) {
// Add deleted_at columns.
$this->columns['deleted_at'] = 'Deleted at';
$this->sort_columns['deleted_at'] = 'deleted_at';
} else {
// Unset deleted_at columns.
unset($this->columns['deleted_at']);
unset($this->sort_columns['deleted_at']);
// if delete_at was the sorting column
// revert back to default sorting.
if ($this->sort == 'deleted_at') {
$this->sort = $this->default_sort;
}
}
}
} }