Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order articles in admin #84

Closed
rafamem opened this issue Oct 28, 2019 · 1 comment
Closed

Order articles in admin #84

rafamem opened this issue Oct 28, 2019 · 1 comment

Comments

@rafamem
Copy link

rafamem commented Oct 28, 2019

How can I order the articles table by published_at?

public function index(ArticleDataTable $dataTable)
{
return $dataTable->render('admin.table', ['link' => route('admin.article.create')]);
}

@ozdemirburak
Copy link
Owner

ozdemirburak commented Oct 29, 2019

Hola Rafael, there is an order variable which is defined in the DataTableController.

So, in the ArticleDataTable file, extend that variable and if the published_at is 4th column in that datatable, and if you'd like to sort articles by descending order, change it like below.

protected $order = [3, 'desc'];

Feel free to ask more, if you have any other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants