Skip to content

Conversation

ejgandelaberon
Copy link
Contributor

This PR aims to give Yajra\DataTables\Services\DataTable base class more flexibility by adding the Illuminate\Support\Traits\Macroable trait which allows us to register custom methods.

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Yajra\DataTables\Services\DataTable::macro('foo', fn (): string => 'bar');
    }
}

$dataTable = new class extends Yajra\DataTables\Services\DataTable {}
$dataTable->foo(); // returns 'bar'

Copy link

Copy link
Owner

@yajra yajra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, will include in v12 release. Thanks!

@yajra yajra changed the title Macroable DataTable Base Class feat: Macroable DataTable Base Class Feb 26, 2025
@yajra yajra merged commit c7090c6 into yajra:master Feb 26, 2025
7 checks passed
@yajra
Copy link
Owner

yajra commented Feb 26, 2025

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

Successfully merging this pull request may close these issues.

3 participants