Eloquent Resource
The easiest way to define what kind of Eloquent Model should be displayed in a Table is by passing the Model class to the $resource
property on your Table component:
php
class Users extends Table
{
protected ?string $resource = User::class;
}
Alternatively, you can define the resource using the resource()
method. It should return an Eloquent Builder instance or a string representing the Model class name. This method is useful when you need to display the data based on additional criteria:
php
use Illuminate\Database\Eloquent\Builder;
class ActiveAdministrators extends Table
{
public function resource(): Builder|string
{
return User::where('role', 'admin')->whereNotNull('activated_at');
}
}