diff --git a/src/Cachet.php b/src/Cachet.php index 3000260d..fdfeecd3 100644 --- a/src/Cachet.php +++ b/src/Cachet.php @@ -3,6 +3,8 @@ namespace Cachet; use Cachet\Http\Middleware\RedirectIfAuthenticated; +use Illuminate\Contracts\Auth\Authenticatable; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; @@ -34,6 +36,18 @@ public static function user(?Request $request = null) return $request->user($guard); } + /** + * Get the configured user model. + * + * @return Model + */ + public static function userModel(): Model + { + $userModel = config('cachet.user_model'); + + return new $userModel; + } + /** * Register the Cachet routes. */ diff --git a/src/Commands/MakeUserCommand.php b/src/Commands/MakeUserCommand.php index 6a8c394e..60f54190 100644 --- a/src/Commands/MakeUserCommand.php +++ b/src/Commands/MakeUserCommand.php @@ -2,6 +2,7 @@ namespace Cachet\Commands; +use Cachet\Cachet; use Illuminate\Console\Command; use function Laravel\Prompts\confirm; @@ -121,7 +122,7 @@ protected function promptIsAdmin(): self */ protected function createUser(): void { - $userModel = config('cachet.user_model'); + $userModel = Cachet::userModel(); $userModel::create([ 'name' => $this->data['name'], diff --git a/src/Filament/Resources/UserResource.php b/src/Filament/Resources/UserResource.php index 895c1253..12a04728 100644 --- a/src/Filament/Resources/UserResource.php +++ b/src/Filament/Resources/UserResource.php @@ -2,6 +2,7 @@ namespace Cachet\Filament\Resources; +use Cachet\Cachet; use Cachet\Filament\Resources\UserResource\Pages; use Cachet\Models\User; use Filament\Forms; @@ -137,6 +138,6 @@ public static function getPluralLabel(): ?string public static function getModel(): string { - return config('cachet.user_model'); + return Cachet::userModel()::class; } }