Using a custom user model in Export action

Hi.. I am trying to use Admin model with export action. I see this documentation: https://filamentphp.com/docs/3.x/actions/prebuilt-actions/export#using-a-custom-user-model But I am little confused.
use App\Models\Admin;
use Illuminate\Contracts\Auth\Authenticatable;

$this->app->bind(Authenticatable::class, Admin::class);
use App\Models\Admin;
use Illuminate\Contracts\Auth\Authenticatable;

$this->app->bind(Authenticatable::class, Admin::class);
When I should bind this ? In AppServiceProvider ? Can any help me ? I just want to use App\Models\Admin model instead of user model.
2 Replies
ConnorHowell
ConnorHowell3mo ago
Yes you'll want to put that in the register() method of a service provider, AppServiceProvider would be a suitable place.
Saifulapm
Saifulapm3mo ago
My Admin model extend to User model
class Admin extends User
{
use HasRoles, HasSuperAdmin;

protected $table = 'users';

protected static function booted()
{
static::addGlobalScope('admin', function (Builder $builder) {
$builder->where('type', 'admin');
});
}
}
class Admin extends User
{
use HasRoles, HasSuperAdmin;

protected $table = 'users';

protected static function booted()
{
static::addGlobalScope('admin', function (Builder $builder) {
$builder->where('type', 'admin');
});
}
}
Still I need to register it ?? But when export finished, notification should be send to admin model .. How I can add admin model to export ?
Want results from more Discord servers?
Add your server
More Posts