Skip to content

Commit d620b53

Browse files
committed
refactor: remove app folder by moving User model and AppServiceProvider to modules
1 parent 8f22bc8 commit d620b53

File tree

11 files changed

+53
-90
lines changed

11 files changed

+53
-90
lines changed

app/Http/Controllers/Controller.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/Models/User.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

app/Providers/AppServiceProvider.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

bootstrap/providers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

33
return [
4-
App\Providers\AppServiceProvider::class,
4+
Modules\Shared\Infrastructure\Provider\SharedServiceProvider::class,
55
Modules\User\Infrastructure\Provider\UserServiceProvider::class,
66
];

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
},
2424
"autoload": {
2525
"psr-4": {
26-
"App\\": "app/",
2726
"Modules\\": "modules/",
2827
"Database\\Factories\\": "database/factories/",
2928
"Database\\Seeders\\": "database/seeders/"
@@ -59,7 +58,7 @@
5958
"@lint",
6059
"@phpstan",
6160
"@php artisan config:clear --ansi",
62-
"@php artisan test"
61+
"./vendor/bin/phpunit"
6362
],
6463
"post-autoload-dump": [
6564
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",

config/auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
'providers' => [
6363
'users' => [
6464
'driver' => 'eloquent',
65-
'model' => env('AUTH_MODEL', App\Models\User::class),
65+
'model' => env('AUTH_MODEL', Modules\User\Infrastructure\Persistence\Eloquent\Model\UserModel::class),
6666
],
6767

6868
// 'users' => [

database/factories/UserFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
use Illuminate\Support\Str;
88

99
/**
10-
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
10+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Modules\User\Infrastructure\Persistence\Eloquent\Model\UserModel>
1111
*/
1212
class UserFactory extends Factory
1313
{
14+
protected $model = \Modules\User\Infrastructure\Persistence\Eloquent\Model\UserModel::class;
15+
1416
/**
1517
* The current password being used by the factory.
1618
*/

database/seeders/DatabaseSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Database\Seeders;
44

5-
use App\Models\User;
65
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
76
use Illuminate\Database\Seeder;
7+
use Modules\User\Infrastructure\Persistence\Eloquent\Model\UserModel as User;
88

99
class DatabaseSeeder extends Seeder
1010
{
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Modules\Shared\Infrastructure\Provider;
6+
7+
use Illuminate\Support\ServiceProvider;
8+
9+
final class SharedServiceProvider extends ServiceProvider
10+
{
11+
public function register(): void
12+
{
13+
//
14+
}
15+
16+
public function boot(): void
17+
{
18+
//
19+
}
20+
}

modules/User/Infrastructure/Persistence/Eloquent/Model/UserModel.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,46 @@
44

55
namespace Modules\User\Infrastructure\Persistence\Eloquent\Model;
66

7+
use Database\Factories\UserFactory;
78
use Illuminate\Database\Eloquent\Concerns\HasUuids;
8-
use Illuminate\Database\Eloquent\Model;
9+
use Illuminate\Database\Eloquent\Factories\HasFactory;
10+
use Illuminate\Foundation\Auth\User as Authenticatable;
11+
use Illuminate\Notifications\Notifiable;
912

10-
final class UserModel extends Model
13+
final class UserModel extends Authenticatable
1114
{
15+
/** @use HasFactory<UserFactory> */
16+
use HasFactory;
17+
1218
use HasUuids;
19+
use Notifiable;
1320

1421
protected $table = 'users';
1522

1623
protected $keyType = 'string';
1724

1825
public $incrementing = false;
1926

27+
/** @var list<string> */
2028
protected $fillable = [
2129
'id',
2230
'name',
2331
'email',
32+
'password',
33+
];
34+
35+
/** @var list<string> */
36+
protected $hidden = [
37+
'password',
38+
'remember_token',
2439
];
40+
41+
/** @return array<string, string> */
42+
protected function casts(): array
43+
{
44+
return [
45+
'email_verified_at' => 'datetime',
46+
'password' => 'hashed',
47+
];
48+
}
2549
}

0 commit comments

Comments
 (0)