Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: DataTable as route action #201

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

Merged
yajra merged 1 commit into yajra:master from ejgandelaberon:datatable-as-route-action
Oct 3, 2025

Conversation

@ejgandelaberon
Copy link
Contributor

@ejgandelaberon ejgandelaberon commented Oct 3, 2025

This PR allows DataTables extending Yajra\DataTables\Services\DataTable to be passed as route action when defining routes:

// web.php
Route::get('/roles', RolesDataTable::class);
// RolesDataTable
class RolesDataTable extends Yajra\DataTables\Services\DataTable
{
 protected ?string $view = 'roles.index';
 public function dataTable(...) {...}
 public function query(...) {...}
 #[\Override]
 protected function viewData(): array
 {
 return [
 'title' => 'Manage Roles',
 'breadcrumbs' => [
 'Administration',
 'ACL',
 'Roles',
 ],
 'widgets' => view('roles.widgets'),
 'rolesCount' => $this->query()->count(),
 ];
 }
}
// roles/index.blade.php
<x-layouts.admin>
 <x-slot:title>{{ $title }}</x-slot>
 <x-breadcrumbs>
 @foreach($breadcrumbs as $breadcrumb)
 <x-breadcrumbs.item>{{ $breadcrumb }}</x-breadcrumbs.item>
 @endforeach
 </x-breadcrumbs>
 {{ $widgets }}
 <x-stat-card :value="$rolesCount" description="Roles Count" />
 <x-datatable-wrapper :data-table="$dataTable" />
</x-layouts.admin>

yajra reacted with heart emoji
Copy link

sonarqubecloud bot commented Oct 3, 2025

@yajra yajra changed the title (削除) DataTable as route action (削除ここまで) (追記) feat: DataTable as route action (追記ここまで) Oct 3, 2025
@yajra yajra merged commit efd7e68 into yajra:master Oct 3, 2025
2 of 3 checks passed
Copy link
Owner

yajra commented Oct 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@yajra yajra yajra approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /