Fix possibly differing model-class

This commit is contained in:
steelvirus
2025-08-06 11:47:30 +02:00
parent de3e9d2ff2
commit ca8451f859
2 changed files with 10 additions and 8 deletions
@@ -2,7 +2,6 @@
namespace Filament\Actions\Exports\Models;
use App\Models\User;
use Carbon\CarbonInterface;
use Exception;
use Filament\Actions\Exports\Exporter;
@@ -59,12 +58,14 @@ class Export extends Model
return $this->belongsTo($authenticatable::class);
}
if (! class_exists(User::class)) {
throw new Exception('No [' . Filament::namespaceFor('Models\\User') . '] model found. Please bind an authenticatable model to the [Illuminate\\Contracts\\Auth\\Authenticatable] interface in a service provider\'s [register()] method.');
$userClass = Filament::namespaceFor('Models\\User');
if (! class_exists($userClass)) {
throw new Exception('No [' . $userClass . '] model found. Please bind an authenticatable model to the [Illuminate\\Contracts\\Auth\\Authenticatable] interface in a service provider\'s [register()] method.');
}
/** @phpstan-ignore-next-line */
return $this->belongsTo(User::class);
return $this->belongsTo($userClass);
}
/**
@@ -2,7 +2,6 @@
namespace Filament\Actions\Imports\Models;
use App\Models\User;
use Carbon\CarbonInterface;
use Exception;
use Filament\Actions\Imports\Importer;
@@ -65,12 +64,14 @@ class Import extends Model
return $this->belongsTo($authenticatable::class);
}
if (! class_exists(User::class)) {
throw new Exception('No [' . Filament::namespaceFor('Models\\User') . '] model found. Please bind an authenticatable model to the [Illuminate\\Contracts\\Auth\\Authenticatable] interface in a service provider\'s [register()] method.');
$userClass = Filament::namespaceFor('Models\\User');
if (! class_exists($userClass)) {
throw new Exception('No [' . $userClass . '] model found. Please bind an authenticatable model to the [Illuminate\\Contracts\\Auth\\Authenticatable] interface in a service provider\'s [register()] method.');
}
/** @phpstan-ignore-next-line */
return $this->belongsTo(User::class);
return $this->belongsTo($userClass);
}
/**