diff --git a/.github/workflows/laravel-7.yml b/.github/workflows/laravel-7.yml deleted file mode 100644 index b70ae5e..0000000 --- a/.github/workflows/laravel-7.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Laravel 7 -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - test: - name: Test - runs-on: ubuntu-18.04 - container: - image: php:7.4-cli - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: PHPUnit - run: | - apt update - apt install -y libzip-dev unzip - pecl install xdebug - docker-php-ext-enable xdebug - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - composer require orchestra/testbench:^v5 --dev - ./vendor/bin/phpunit --coverage-clover coverage.xml tests/ - - name: codecov - uses: codecov/codecov-action@v1 - with: - name: laravel-6 diff --git a/.github/workflows/laravel-6.yml b/.github/workflows/laravel-8.yml similarity index 79% rename from .github/workflows/laravel-6.yml rename to .github/workflows/laravel-8.yml index 7aa2f3a..8af068b 100644 --- a/.github/workflows/laravel-6.yml +++ b/.github/workflows/laravel-8.yml @@ -1,4 +1,4 @@ -name: Laravel 6 +name: Laravel 8 on: push: branches: @@ -22,8 +22,8 @@ jobs: pecl install xdebug docker-php-ext-enable xdebug curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - composer require orchestra/testbench:^v4 --dev - ./vendor/bin/phpunit --coverage-clover coverage.xml tests/ + composer require orchestra/testbench:^v8 --dev + ./vendor/bin/phpunit --coverage-clover coverage.xml --coverage-filter src/ tests/ - name: codecov uses: codecov/codecov-action@v1 with: diff --git a/README.md b/README.md index 3c2a2a7..89f77b4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Laravel UI Socialite -[![Laravel 6](https://github.com/laravel-fans/laravel-ui-socialite/workflows/Laravel%206/badge.svg)](https://github.com/laravel-fans/laravel-ui-socialite/actions) -[![Laravel 7](https://github.com/laravel-fans/laravel-ui-socialite/workflows/Laravel%207/badge.svg)](https://github.com/laravel-fans/laravel-ui-socialite/actions) +[![Laravel 8](https://github.com/laravel-fans/laravel-ui-socialite/workflows/Laravel%208/badge.svg)](https://github.com/laravel-fans/laravel-ui-socialite/actions) [![codecov](https://codecov.io/gh/laravel-fans/laravel-ui-socialite/branch/main/graph/badge.svg)](https://codecov.io/gh/laravel-fans/laravel-ui-socialite) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/laravel-fans/laravel-ui-socialite/blob/main/LICENSE) @@ -13,8 +12,6 @@ When logged in, you can link all providers to the current user, and login with t Special handling for [WeChat](https://sinkcup.github.io/laravel-socialite-wechat-login). -supporting Laravel 6, 7... - ## install ``` @@ -22,6 +19,7 @@ composer require laravel-fans/ui-socialite php artisan ui vue php artisan ui:auth php artisan ui:socialite +php artisan vendor:publish --provider="LaravelFans\UiSocialite\UiSocialiteServiceProvider" php artisan migrate ``` @@ -44,7 +42,7 @@ add to `.env`: AUTH_SOCIAL_LOGIN_PROVIDERS=Facebook,Twitter,Linkedin,Google,GitHub,GitLab,Bitbucket,wechat_web,wechat_service_account GITHUB_CLIENT_ID=foo GITHUB_CLIENT_SECRET=bar -GITHUB_CALLBACK_URL=http://localhost/login/github/callback +GITHUB_CALLBACK_URL=http://127.0.0.1:8000/login/github/callback GITHUB_SCOPES=user:email,public_repo # disable password login diff --git a/composer.json b/composer.json index 18973bf..3f6fa57 100644 --- a/composer.json +++ b/composer.json @@ -3,12 +3,12 @@ "description": "Automatically generate database, pages, and routes for Laravel Socialite", "type": "library", "require": { - "php": ">=7.2", - "laravel/framework": "^v6.18.37 | ^v7.28.1", + "php": ">=7.3", + "laravel/framework": "^v8.1.0", "laravel/socialite": ">=v4.4.1", "doctrine/dbal": ">=2.9", "phlak/semver": ">=2.0", - "laravel/ui": ">=v1.2.0" + "laravel/ui": ">=v3.0.0" }, "suggest": { "laravel-fans/socialite-providers": "Providers for Laravel Socialite" @@ -28,6 +28,7 @@ "autoload-dev": { "psr-4": { "App\\": "vendor/orchestra/testbench-core/laravel/app/", + "Database\\Factories\\": "vendor/orchestra/testbench-core/laravel/database/factories/", "LaravelFans\\UiSocialite\\Tests\\": "tests/" } }, @@ -40,9 +41,9 @@ } }, "require-dev": { - "orchestra/testbench": "^v4.8.0 | ^v5.5.0", + "orchestra/testbench": "^v6.0.0", "squizlabs/php_codesniffer": ">=3.5.6", "fzaninotto/faker": ">=v1.9.1", - "phpunit/phpunit": "^8.5.8" + "phpunit/phpunit": "^9.3.8" } } diff --git a/src/config/auth.php b/config/auth.php similarity index 100% rename from src/config/auth.php rename to config/auth.php diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php new file mode 100644 index 0000000..621a24e --- /dev/null +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users'); + } +} diff --git a/src/database/migrations/2018_01_28_095600_create_social_accounts_table.php b/database/migrations/2018_01_28_095600_create_social_accounts_table.php similarity index 100% rename from src/database/migrations/2018_01_28_095600_create_social_accounts_table.php rename to database/migrations/2018_01_28_095600_create_social_accounts_table.php diff --git a/src/database/migrations/2018_01_28_113309_change_password_to_nullable_of_users_table.php b/database/migrations/2018_01_28_113309_change_password_to_nullable_of_users_table.php similarity index 100% rename from src/database/migrations/2018_01_28_113309_change_password_to_nullable_of_users_table.php rename to database/migrations/2018_01_28_113309_change_password_to_nullable_of_users_table.php diff --git a/src/database/migrations/2019_01_12_144925_add_avatar_to_users_table.php b/database/migrations/2019_01_12_144925_add_avatar_to_users_table.php similarity index 100% rename from src/database/migrations/2019_01_12_144925_add_avatar_to_users_table.php rename to database/migrations/2019_01_12_144925_add_avatar_to_users_table.php diff --git a/src/database/migrations/2019_06_26_020655_add_nickname_to_social_accounts_table.php b/database/migrations/2019_06_26_020655_add_nickname_to_social_accounts_table.php similarity index 100% rename from src/database/migrations/2019_06_26_020655_add_nickname_to_social_accounts_table.php rename to database/migrations/2019_06_26_020655_add_nickname_to_social_accounts_table.php diff --git a/src/database/migrations/2019_06_26_020724_add_name_to_social_accounts_table.php b/database/migrations/2019_06_26_020724_add_name_to_social_accounts_table.php similarity index 100% rename from src/database/migrations/2019_06_26_020724_add_name_to_social_accounts_table.php rename to database/migrations/2019_06_26_020724_add_name_to_social_accounts_table.php diff --git a/src/database/migrations/2019_06_26_020733_add_email_to_social_accounts_table.php b/database/migrations/2019_06_26_020733_add_email_to_social_accounts_table.php similarity index 100% rename from src/database/migrations/2019_06_26_020733_add_email_to_social_accounts_table.php rename to database/migrations/2019_06_26_020733_add_email_to_social_accounts_table.php diff --git a/src/database/migrations/2019_06_26_020739_add_avatar_to_social_accounts_table.php b/database/migrations/2019_06_26_020739_add_avatar_to_social_accounts_table.php similarity index 100% rename from src/database/migrations/2019_06_26_020739_add_avatar_to_social_accounts_table.php rename to database/migrations/2019_06_26_020739_add_avatar_to_social_accounts_table.php diff --git a/src/database/migrations/2019_06_26_020745_add_raw_to_social_accounts_table.php b/database/migrations/2019_06_26_020745_add_raw_to_social_accounts_table.php similarity index 100% rename from src/database/migrations/2019_06_26_020745_add_raw_to_social_accounts_table.php rename to database/migrations/2019_06_26_020745_add_raw_to_social_accounts_table.php diff --git a/phpunit.xml b/phpunit.xml index bbb6152..8da9454 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,39 +1,31 @@ - - - - ./tests/Unit - - - - ./tests/Feature - - - - - ./src - - - - - - - - - - - - - - - - + + + + ./src + + + + + + + + ./tests/Unit + + + ./tests/Feature + + + + + + + + + + + + + + diff --git a/src/Socialite/Controllers/Controller.php b/src/Controllers/Controller.php similarity index 94% rename from src/Socialite/Controllers/Controller.php rename to src/Controllers/Controller.php index 1db8bfd..4d035c9 100644 --- a/src/Socialite/Controllers/Controller.php +++ b/src/Controllers/Controller.php @@ -1,6 +1,6 @@ 'array', diff --git a/src/Socialite/stubs/database/factories/SocialAccountFactory.stub b/src/Socialite/stubs/database/factories/SocialAccountFactory.stub deleted file mode 100644 index 5399263..0000000 --- a/src/Socialite/stubs/database/factories/SocialAccountFactory.stub +++ /dev/null @@ -1,32 +0,0 @@ -define(SocialAccount::class, function (Faker $faker) { - return [ - 'user_id' => $faker->randomNumber(), - 'provider' => $faker->word, - 'provider_user_id' => $faker->word . $faker->randomNumber(), - 'access_token' => $faker->md5, - 'refresh_token' => null, - 'expires_in' => null, - 'nickname' => $faker->lastName, - 'name' => $faker->name, - 'email' => $faker->safeEmail, - 'avatar' => $faker->imageUrl(), - 'raw' => null, - ]; -}); diff --git a/src/Socialite/stubs/routes.stub b/src/Socialite/stubs/routes.stub deleted file mode 100644 index 9e2a6bb..0000000 --- a/src/Socialite/stubs/routes.stub +++ /dev/null @@ -1,8 +0,0 @@ - -Route::get('login/{provider}', 'Auth\LoginController@redirectToProvider'); -Route::get('login/{provider}/callback', 'Auth\LoginController@handleProviderCallback'); - -Route::get('settings/profile', 'Settings\ProfileController@edit')->name('profile.edit'); -Route::put('settings/profile', 'Settings\ProfileController@update')->name('profile.update'); - -Auth::routes(config('auth.options') ?? []); diff --git a/src/SocialiteCommand.php b/src/SocialiteCommand.php index 6cf0934..7844bbd 100644 --- a/src/SocialiteCommand.php +++ b/src/SocialiteCommand.php @@ -96,7 +96,7 @@ protected function exportViews() } $version = new Version(app()->version()); - $path = __DIR__ . '/Socialite/' . $this->argument('type') . '-stubs/'; + $path = __DIR__ . '/' . $this->argument('type') . '-stubs/'; $file_for_version = $key . '_' . $version->major . '.' . $version->minor; $file_path = file_exists($path . $file_for_version) ? $path . $file_for_version : $path . $key; copy($file_path, $view); @@ -119,16 +119,12 @@ protected function exportBackend() $this->compileControllerStub('settings/ProfileController.stub') ); copy( - __DIR__ . '/Socialite/stubs/database/factories/SocialAccountFactory.stub', - database_path('factories/SocialAccountFactory.php') - ); - copy( - __DIR__ . '/Socialite/stubs/tests/TestCase.stub', + __DIR__ . '/stubs/tests/TestCase.stub', app_path() . '/../tests/TestCase.php' ); $web_routes = file_get_contents(base_path('routes/web.php')); - foreach (explode("\n", file_get_contents(__DIR__ . '/Socialite/stubs/routes.stub')) as $line) { + foreach (explode("\n", file_get_contents(__DIR__ . '/stubs/routes.stub')) as $line) { if (empty($line)) { continue; } @@ -167,7 +163,7 @@ protected function compileStub(string $path) return str_replace( '{{namespace}}', $this->laravel->getNamespace(), - file_get_contents(__DIR__ . '/Socialite/stubs/' . $path) + file_get_contents(__DIR__ . '/stubs/' . $path) ); } diff --git a/src/SocialiteService.php b/src/SocialiteService.php index fb96430..1b81a21 100644 --- a/src/SocialiteService.php +++ b/src/SocialiteService.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Log; use Laravel\Socialite\Facades\Socialite; +use LaravelFans\UiSocialite\Models\SocialAccount; class SocialiteService { diff --git a/src/UiSocialiteServiceProvider.php b/src/UiSocialiteServiceProvider.php index 01e3160..41fd35b 100644 --- a/src/UiSocialiteServiceProvider.php +++ b/src/UiSocialiteServiceProvider.php @@ -18,11 +18,10 @@ public function boot() SocialiteCommand::class, ]); } - // HACK: package migrations be migrated before laravel migrations when run test - // error: There is no column with name 'password' on table 'users'. - if ($this->app->config['app']['name'] != 'testbench') { - $this->loadMigrationsFrom(__DIR__ . '/database/migrations'); - } + + $this->publishes([ + __DIR__ . '/../database/migrations' => database_path('migrations'), + ], 'ui-socialite-migrations'); } /** @@ -32,7 +31,7 @@ public function boot() */ public function register() { - $this->mergeConfigFrom(__DIR__ . '/config/auth.php', 'auth'); + $this->mergeConfigFrom(__DIR__ . '/../config/auth.php', 'auth'); $this->app->singleton(SocialiteService::class, function ($app) { return new SocialiteService($app); }); diff --git a/src/Socialite/bootstrap-stubs/auth/login.stub b/src/bootstrap-stubs/auth/login.stub similarity index 100% rename from src/Socialite/bootstrap-stubs/auth/login.stub rename to src/bootstrap-stubs/auth/login.stub diff --git a/src/Socialite/bootstrap-stubs/settings/profile.stub b/src/bootstrap-stubs/settings/profile.stub similarity index 100% rename from src/Socialite/bootstrap-stubs/settings/profile.stub rename to src/bootstrap-stubs/settings/profile.stub diff --git a/src/Socialite/stubs/controllers/auth/LoginController.stub b/src/stubs/controllers/auth/LoginController.stub similarity index 92% rename from src/Socialite/stubs/controllers/auth/LoginController.stub rename to src/stubs/controllers/auth/LoginController.stub index 9404261..c110c18 100644 --- a/src/Socialite/stubs/controllers/auth/LoginController.stub +++ b/src/stubs/controllers/auth/LoginController.stub @@ -2,7 +2,7 @@ namespace {{namespace}}Http\Controllers\Auth; -use LaravelFans\UiSocialite\Socialite\Controllers\SocialiteLoginController; +use LaravelFans\UiSocialite\Controllers\SocialiteLoginController; class LoginController extends SocialiteLoginController { diff --git a/src/Socialite/stubs/controllers/settings/ProfileController.stub b/src/stubs/controllers/settings/ProfileController.stub similarity index 53% rename from src/Socialite/stubs/controllers/settings/ProfileController.stub rename to src/stubs/controllers/settings/ProfileController.stub index 32b760c..27bdeb4 100644 --- a/src/Socialite/stubs/controllers/settings/ProfileController.stub +++ b/src/stubs/controllers/settings/ProfileController.stub @@ -2,7 +2,7 @@ namespace {{namespace}}Http\Controllers\Settings; -use LaravelFans\UiSocialite\Socialite\Controllers\Settings\ProfileController as PackageProfileController; +use LaravelFans\UiSocialite\Controllers\Settings\ProfileController as PackageProfileController; class ProfileController extends PackageProfileController { diff --git a/src/stubs/routes.stub b/src/stubs/routes.stub new file mode 100644 index 0000000..0bd2e24 --- /dev/null +++ b/src/stubs/routes.stub @@ -0,0 +1,8 @@ + +Route::get('login/{provider}', [App\Http\Controllers\Auth\LoginController::class, 'redirectToProvider']); +Route::get('login/{provider}/callback', [App\Http\Controllers\Auth\LoginController::class, 'handleProviderCallback']); + +Route::get('settings/profile', [App\Http\Controllers\Settings\ProfileController::class, 'edit'])->name('profile.edit'); +Route::put('settings/profile', [App\Http\Controllers\Settings\ProfileController::class, 'update'])->name('profile.update'); + +Auth::routes(config('auth.options') ?? []); diff --git a/src/Socialite/stubs/tests/TestCase.stub b/src/stubs/tests/TestCase.stub similarity index 100% rename from src/Socialite/stubs/tests/TestCase.stub rename to src/stubs/tests/TestCase.stub diff --git a/tests/Feature/ProfileControllerTest.php b/tests/Feature/ProfileControllerTest.php index 70b2d76..0406c7a 100644 --- a/tests/Feature/ProfileControllerTest.php +++ b/tests/Feature/ProfileControllerTest.php @@ -2,9 +2,9 @@ namespace LaravelFans\UiSocialite\Tests\Feature; -use App\User; +use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; -use LaravelFans\UiSocialite\SocialAccount; +use LaravelFans\UiSocialite\Models\SocialAccount; use LaravelFans\UiSocialite\Tests\TestCase; class ProfileControllerTest extends TestCase @@ -13,8 +13,9 @@ class ProfileControllerTest extends TestCase public function testEdit() { - $user = factory(User::class)->create(); - $social_account = factory(SocialAccount::class)->create(['user_id' => $user->id]); + $user = User::factory()->create(); + $this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class); + $social_account = SocialAccount::factory()->create(['user_id' => $user->id]); $response = $this->actingAs($user)->get('/settings/profile'); $response->assertViewIs('settings.profile'); @@ -27,8 +28,8 @@ public function testEditShouldHideWeChatWebWhenVisitFromWeChatApp() { $providers = ['github', 'wechat_service_account']; $this->app['config']->set('auth.social_login.providers', array_merge($providers, ['wechat_web'])); - $user = factory(User::class)->create(); - $social_account = factory(SocialAccount::class)->create(['user_id' => $user->id]); + $user = User::factory()->create(); + $social_account = SocialAccount::factory()->create(['user_id' => $user->id]); $response = $this->actingAs($user) ->withHeader( 'user-agent', @@ -46,7 +47,7 @@ public function testEditShouldHideWeChatServiceAccountWhenVisitFromWeb() { $providers = ['github', 'wechat_web']; $this->app['config']->set('auth.social_login.providers', array_merge($providers, ['wechat_service_account'])); - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->get('/settings/profile'); $response->assertViewIs('settings.profile'); @@ -57,7 +58,7 @@ public function testEditShouldHideWeChatServiceAccountWhenVisitFromWeb() public function testUpdate() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $data = [ 'email' => $this->faker->safeEmail, 'name' => $this->faker->name, diff --git a/tests/Feature/SocialiteLoginControllerTest.php b/tests/Feature/SocialiteLoginControllerTest.php index d6b3670..5a14aae 100644 --- a/tests/Feature/SocialiteLoginControllerTest.php +++ b/tests/Feature/SocialiteLoginControllerTest.php @@ -2,12 +2,11 @@ namespace LaravelFans\UiSocialite\Tests\Feature; -use App\User; +use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Laravel\Socialite\Facades\Socialite; use Mockery; -use LaravelFans\UiSocialite\SocialAccount; -use LaravelFans\UiSocialite\Socialite\Controllers\SocialiteLoginController; +use LaravelFans\UiSocialite\Models\SocialAccount; use LaravelFans\UiSocialite\SocialiteService; use LaravelFans\UiSocialite\Tests\TestCase; @@ -116,8 +115,8 @@ public function testHandleProviderCallbackForOldUser() $this->app['config']->set('services.' . $provider, $this->serviceConfig); $abstractUser = Mockery::mock('Laravel\Socialite\Two\User'); $abstractUser->token = $this->faker->md5; - $user = factory(User::class)->create(); - $socialAccount = factory(SocialAccount::class)->create([ + $user = User::factory()->create(); + $socialAccount = SocialAccount::factory()->create([ 'user_id' => $user->id, 'provider' => $provider, ]); diff --git a/tests/SocialAccountFactory.stub b/tests/SocialAccountFactory.stub new file mode 100644 index 0000000..a4ca48d --- /dev/null +++ b/tests/SocialAccountFactory.stub @@ -0,0 +1,38 @@ + $this->faker->randomNumber(), + 'provider' => $this->faker->word, + 'provider_user_id' => $this->faker->word . $this->faker->randomNumber(), + 'access_token' => $this->faker->md5, + 'refresh_token' => null, + 'expires_in' => null, + 'nickname' => $this->faker->lastName, + 'name' => $this->faker->name, + 'email' => $this->faker->safeEmail, + 'avatar' => $this->faker->imageUrl(), + 'raw' => null, + ]; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 4d82b05..333f544 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -51,24 +51,16 @@ protected function setUp(): void @mkdir($laravel_path . '/tests/Feature/', 0755, true); @unlink($laravel_path . '/routes/web.php'); touch($laravel_path . '/routes/web.php'); - copy(__DIR__ . '/User.stub', $laravel_path . '/app/User.php'); + @mkdir($laravel_path . '/database/factories/LaravelFans/UiSocialite/Models/', 0755, true); copy(__DIR__ . '/UserFactory.stub', $laravel_path . '/database/factories/UserFactory.php'); + copy(__DIR__ . '/SocialAccountFactory.stub', $laravel_path . '/database/factories/LaravelFans/UiSocialite/Models/SocialAccountFactory.php'); + @mkdir($laravel_path . '/app/Models/'); + copy(__DIR__ . '/User.stub', $laravel_path . '/app/Models/User.php'); $this->artisan('ui:auth', ['--force' => true])->run(); $this->artisan('ui:socialite', ['--force' => true])->run(); + $this->artisan('vendor:publish', ['--provider' => "LaravelFans\UiSocialite\UiSocialiteServiceProvider"])->run(); - // TODO crash on local and Github Actions when orchestra/testbench v5(Laravel 7) - try { - $this->loadLaravelMigrations(); - } catch (\PDOException $e) { - echo $e->getMessage() . "\n"; - } - $this->loadMigrationsFrom(__DIR__ . '/../src/database/migrations'); - // TODO crash on GitHub Actions when orchestra/testbench v5(Laravel 7) - try { - $this->artisan('migrate')->run(); - } catch (\PDOException $e) { - echo $e->getMessage() . "\n"; - } + $this->artisan('migrate')->run(); $this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class); $this->app->make('Illuminate\Contracts\Http\Kernel') ->pushMiddleware('Illuminate\Session\Middleware\StartSession'); @@ -94,5 +86,6 @@ protected function getEnvironmentSetUp($app) 'database' => ':memory:', 'prefix' => '', ]); + $app['config']->set('auth.providers.users.model', 'App\\Models\\User'); } } diff --git a/tests/User.stub b/tests/User.stub index 75741ae..1daed8e 100644 --- a/tests/User.stub +++ b/tests/User.stub @@ -1,11 +1,17 @@ 'datetime', + ]; } diff --git a/tests/UserFactory.stub b/tests/UserFactory.stub index 5e516ce..bdea1a3 100644 --- a/tests/UserFactory.stub +++ b/tests/UserFactory.stub @@ -1,27 +1,33 @@ define(User::class, function (Faker $faker) { - return [ - 'name' => $faker->name, - 'email' => $faker->unique()->safeEmail, - 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password - 'remember_token' => Str::random(10), - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'name' => $this->faker->name, + 'email' => $this->faker->unique()->safeEmail, + 'email_verified_at' => now(), + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'remember_token' => Str::random(10), + ]; + } +}