yajra / laravel-datatables-html

Laravel DataTables HTML Builder Plugin
https://yajrabox.com/docs/laravel-datatables/html-installation
MIT License
272 stars 61 forks source link

Setting attribute via call method is not working #226

Closed ajaybhargav closed 3 weeks ago

ajaybhargav commented 2 months ago

Summary of problem or feature request

I am creating buttons using Button::make and setting attributes using call method. But I am getting exception

Code snippet of problem

            Button::make("pdfHtml5")
                ->text("<i class='fa fa-file-pdf text-125 text-danger'></i> <span class='d-none'>Export to PDF</span>")
                ->className("btn-light-default btn-bgc-white btn-h-outline-primary btn-a-outline-primary")
                ->autoPrint(false)
                ->exportOptions([
                    'columns' => $this->getExportColumns(),
                ])
                ->orientation('landscape')
                ->title($this->getExportTitle())
                ->customize($this->getPdfCustomize()),

Getting exception e.g.

[2024-09-08 12:13:16] production.ERROR: Method Yajra\DataTables\Html\Button::orientation does not exist. {"userId":1,"exception":"[object] (BadMethodCallException(code: 0): Method Yajra\\DataTables\\Html\\Button::orientation does not exist.

If i define function like this in vendor/yajra/laravel-datatables-html/src/Html/Button.php:

public function orientation(string $or): static
{
        $this->attributes['orientation'] = $or;

        return $this;
}

evereything works fine. It was working fine until the recent update.

System details

yajra commented 2 months ago

Thanks for reporting, might be due to the added macro on button builder, which overrides the Fluent class magic call functionality.

I will review it and patch it as soon as I can. Please do not hesitate to submit a PR. Thanks!

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been inactive for 7 days since being marked as stale.