Skip to content

Commit 5cb444c

Browse files
committed
Use Cachet class to determine correct User model
1 parent 028f9d3 commit 5cb444c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/Cachet.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Cachet;
44

55
use Cachet\Http\Middleware\RedirectIfAuthenticated;
6+
use Illuminate\Contracts\Auth\Authenticatable;
7+
use Illuminate\Database\Eloquent\Model;
68
use Illuminate\Http\Request;
79
use Illuminate\Support\Facades\Route;
810

@@ -34,6 +36,18 @@ public static function user(?Request $request = null)
3436
return $request->user($guard);
3537
}
3638

39+
/**
40+
* Get the configured user model.
41+
*
42+
* @return Model<Authenticatable>
43+
*/
44+
public static function userModel(): Model
45+
{
46+
$userModel = config('cachet.user_model');
47+
48+
return new $userModel;
49+
}
50+
3751
/**
3852
* Register the Cachet routes.
3953
*/

src/Commands/MakeUserCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Cachet\Commands;
44

5+
use Cachet\Cachet;
56
use Illuminate\Console\Command;
67

78
use function Laravel\Prompts\confirm;
@@ -121,7 +122,7 @@ protected function promptIsAdmin(): self
121122
*/
122123
protected function createUser(): void
123124
{
124-
$userModel = config('cachet.user_model');
125+
$userModel = Cachet::userModel();
125126

126127
$userModel::create([
127128
'name' => $this->data['name'],

src/Filament/Resources/UserResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Cachet\Filament\Resources;
44

5+
use Cachet\Cachet;
56
use Cachet\Filament\Resources\UserResource\Pages;
67
use Cachet\Models\User;
78
use Filament\Forms;
@@ -137,6 +138,6 @@ public static function getPluralLabel(): ?string
137138

138139
public static function getModel(): string
139140
{
140-
return config('cachet.user_model');
141+
return Cachet::userModel()::class;
141142
}
142143
}

0 commit comments

Comments
 (0)