You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a generic class taken from the skeleton example on docs
If I add a constructor to it so an example:
namespace App\Datatables\Users;
use Flavorly\VanillaComponents\Datatables\Datatable;
use Flavorly\VanillaComponents\Datatables\Options\General\Options;
class User extends Datatable
{
public function __construct($id)
{
$this->id = $id;
{
public function query(): mixed
{
return User::query()->where('user_id', $this->id);
// You can also return a closure or a relationship here
// return fn() => User::query()->where('user_id', auth()->id());
// Auth::user()->payments();
}
public function fetchEndpoint(): ?string
{
// Endpoint where the datatable will fetch the data from
return route('datatables.demo');
}
public function columns(): array
{
return [
// Columns go here
];
}
public function filters(): array
{
return [
// Filters go here
];
}
public function actions(): array
{
return [
// Actions go here
];
}
public function options(): array| Options
{
return Options::make()->refreshable()->hideSearchBar();
}
}
I get the following error. I tried also defining the Name attribute on the class but that did not seem to work either.
Flavorly\VanillaComponents\Datatables\Datatable::getName(): Return value must be of type string, null returned
The text was updated successfully, but these errors were encountered:
juliancarstairs
changed the title
Adding constructor to class for Datatable requires a
Adding constructor to class for Datatable requires a Name
Aug 10, 2023
All Datatables should implement a getName() name, maybe i forgot to mention on the docs, this is because filters and other stuff are prefixed by the name, so in case you want to have 2 datatables on same page, they would still work normally.
I think you could implement an interface to ensure that this property is available on all Datatables, currently it uses the reflection class to set get name. just a thought. thanks
I have a generic class taken from the skeleton example on docs
If I add a constructor to it so an example:
I get the following error. I tried also defining the Name attribute on the class but that did not seem to work either.
Flavorly\VanillaComponents\Datatables\Datatable::getName(): Return value must be of type string, null returned
The text was updated successfully, but these errors were encountered: