From 5169e1a8498a8a1c55ec3bfb8b506e20be7f1d65 Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Wed, 20 Dec 2023 16:51:06 +0100 Subject: [PATCH 1/6] Update page title in welcome.blade.php --- resources/views/welcome.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 638ec96..7563c62 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -4,7 +4,7 @@ - Laravel + Maestro From 1aec02f6b1e9a27dc7a4e033cae0d8beacb145b0 Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Thu, 21 Dec 2023 11:28:37 +0100 Subject: [PATCH 2/6] Refactor code to improve performance and readability --- .github/workflows/tests.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..5e086e8 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,33 @@ +name: Tests + +on: + push: + branches: + - main + - dev + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + extensions: mbstring, sqlite3 + + - name: Install dependencies + run: composer install --no-interaction + + - name: Create environment file + run: cp .env.example .env + + - name: Generate application key + run: php artisan key:generate + + - name: Run tests + run: php artisan test From 1f8541ddda22d91651b4e0e5bd120fb42bb6a84f Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Thu, 21 Dec 2023 11:31:58 +0100 Subject: [PATCH 3/6] Update PHP version to 8.3 --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5e086e8..637a654 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,7 +17,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.3' extensions: mbstring, sqlite3 - name: Install dependencies From 08aebac4f6066ad2f5f6cbdd35d4ccb502c095bd Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Tue, 26 Dec 2023 23:14:55 +0100 Subject: [PATCH 4/6] Remove Sanctum package, connect database & created first migration --- app/Http/Kernel.php | 1 - app/Models/User.php | 3 +- composer.json | 1 - composer.lock | 168 ++++++------------ config/cors.php | 2 +- config/sanctum.php | 83 --------- ...000_create_password_reset_tokens_table.php | 28 --- ..._08_19_000000_create_failed_jobs_table.php | 32 ---- ...01_create_personal_access_tokens_table.php | 33 ---- ... 2023_12_26_213315_create_users_table.php} | 6 +- 10 files changed, 57 insertions(+), 300 deletions(-) delete mode 100644 config/sanctum.php delete mode 100644 database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php delete mode 100644 database/migrations/2019_08_19_000000_create_failed_jobs_table.php delete mode 100644 database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php rename database/migrations/{2014_10_12_000000_create_users_table.php => 2023_12_26_213315_create_users_table.php} (80%) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 494c050..f09a015 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -39,7 +39,6 @@ class Kernel extends HttpKernel ], 'api' => [ - // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], diff --git a/app/Models/User.php b/app/Models/User.php index 4d7f70f..6bd3a59 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -6,11 +6,10 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; -use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { - use HasApiTokens, HasFactory, Notifiable; + use HasFactory, Notifiable; /** * The attributes that are mass assignable. diff --git a/composer.json b/composer.json index 8a3d72d..115d03f 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,6 @@ "php": "^8.1", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.10", - "laravel/sanctum": "^3.3", "laravel/tinker": "^2.8" }, "require-dev": { diff --git a/composer.lock b/composer.lock index a9dad77..87ee4ce 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9c491b8531eec05ba41a11d9276a5749", + "content-hash": "2db4f4f45d5f19c3d1d1d0592de24b8a", "packages": [ { "name": "brick/math", @@ -63,26 +63,26 @@ }, { "name": "carbonphp/carbon-doctrine-types", - "version": "3.1.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/CarbonPHP/carbon-doctrine-types.git", - "reference": "a31d3358a2a5d6ae947df1691d1f321418a5f3d5" + "reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/a31d3358a2a5d6ae947df1691d1f321418a5f3d5", - "reference": "a31d3358a2a5d6ae947df1691d1f321418a5f3d5", + "url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/99f76ffa36cce3b70a4a6abce41dba15ca2e84cb", + "reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^7.4 || ^8.0" }, "conflict": { - "doctrine/dbal": "<4.0.0 || >=5.0.0" + "doctrine/dbal": "<3.7.0 || >=4.0.0" }, "require-dev": { - "doctrine/dbal": "^4.0.0", + "doctrine/dbal": "^3.7.0", "nesbot/carbon": "^2.71.0 || ^3.0.0", "phpunit/phpunit": "^10.3" }, @@ -112,7 +112,7 @@ ], "support": { "issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues", - "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.1.0" + "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/2.1.0" }, "funding": [ { @@ -128,7 +128,7 @@ "type": "tidelift" } ], - "time": "2023-12-10T15:33:53+00:00" + "time": "2023-12-11T17:09:12+00:00" }, { "name": "dflydev/dot-access-data", @@ -1047,16 +1047,16 @@ }, { "name": "laravel/framework", - "version": "v10.38.0", + "version": "v10.38.2", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "531732a17e4d0fa4fc4fb987a72abbdb93537d3a" + "reference": "43da808391da3540d44a8dfeb4e46da4ad8f5723" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/531732a17e4d0fa4fc4fb987a72abbdb93537d3a", - "reference": "531732a17e4d0fa4fc4fb987a72abbdb93537d3a", + "url": "https://api.github.com/repos/laravel/framework/zipball/43da808391da3540d44a8dfeb4e46da4ad8f5723", + "reference": "43da808391da3540d44a8dfeb4e46da4ad8f5723", "shasum": "" }, "require": { @@ -1102,6 +1102,8 @@ "voku/portable-ascii": "^2.0" }, "conflict": { + "carbonphp/carbon-doctrine-types": ">=3.0", + "doctrine/dbal": ">=4.0", "tightenco/collect": "<5.5.33" }, "provide": { @@ -1213,6 +1215,7 @@ "files": [ "src/Illuminate/Collections/helpers.php", "src/Illuminate/Events/functions.php", + "src/Illuminate/Filesystem/functions.php", "src/Illuminate/Foundation/helpers.php", "src/Illuminate/Support/helpers.php" ], @@ -1245,7 +1248,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-19T14:59:00+00:00" + "time": "2023-12-22T14:39:10+00:00" }, { "name": "laravel/prompts", @@ -1304,72 +1307,6 @@ }, "time": "2023-10-27T13:53:59+00:00" }, - { - "name": "laravel/sanctum", - "version": "v3.3.2", - "source": { - "type": "git", - "url": "https://github.com/laravel/sanctum.git", - "reference": "e1a272893bec13cf135627f7e156030b3afe1e60" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/sanctum/zipball/e1a272893bec13cf135627f7e156030b3afe1e60", - "reference": "e1a272893bec13cf135627f7e156030b3afe1e60", - "shasum": "" - }, - "require": { - "ext-json": "*", - "illuminate/console": "^9.21|^10.0", - "illuminate/contracts": "^9.21|^10.0", - "illuminate/database": "^9.21|^10.0", - "illuminate/support": "^9.21|^10.0", - "php": "^8.0.2" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "orchestra/testbench": "^7.28.2|^8.8.3", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Sanctum\\SanctumServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Laravel\\Sanctum\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.", - "keywords": [ - "auth", - "laravel", - "sanctum" - ], - "support": { - "issues": "https://github.com/laravel/sanctum/issues", - "source": "https://github.com/laravel/sanctum" - }, - "time": "2023-11-03T13:42:14+00:00" - }, { "name": "laravel/serializable-closure", "version": "v1.3.3", @@ -6202,7 +6139,6 @@ "laravel/framework": "^10.28.0", "laravel/pint": "^1.13.3", "laravel/sail": "^1.25.0", - "laravel/sanctum": "^3.3.1", "laravel/tinker": "^2.8.2", "nunomaduro/larastan": "^2.6.4", "orchestra/testbench-core": "^8.13.0", @@ -6383,23 +6319,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.10", + "version": "10.1.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "599109c8ca6bae97b23482d557d2874c25a65e59" + "reference": "78c3b7625965c2513ee96569a4dbb62601784145" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/599109c8ca6bae97b23482d557d2874c25a65e59", - "reference": "599109c8ca6bae97b23482d557d2874c25a65e59", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/78c3b7625965c2513ee96569a4dbb62601784145", + "reference": "78c3b7625965c2513ee96569a4dbb62601784145", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1", "phpunit/php-file-iterator": "^4.0", "phpunit/php-text-template": "^3.0", @@ -6449,7 +6385,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.10" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.11" }, "funding": [ { @@ -6457,7 +6393,7 @@ "type": "github" } ], - "time": "2023-12-11T06:28:43+00:00" + "time": "2023-12-21T15:38:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -7049,20 +6985,20 @@ }, { "name": "sebastian/complexity", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -7071,7 +7007,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.1-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -7095,7 +7031,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -7103,20 +7039,20 @@ "type": "github" } ], - "time": "2023-09-28T11:50:59+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", - "version": "5.0.3", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f", "shasum": "" }, "require": { @@ -7129,7 +7065,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -7162,7 +7098,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.0" }, "funding": [ { @@ -7170,7 +7106,7 @@ "type": "github" } ], - "time": "2023-05-01T07:48:21+00:00" + "time": "2023-12-22T10:55:06+00:00" }, { "name": "sebastian/environment", @@ -7378,20 +7314,20 @@ }, { "name": "sebastian/lines-of-code", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/649e40d279e243d985aa8fb6e74dd5bb28dc185d", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -7424,7 +7360,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -7432,7 +7368,7 @@ "type": "github" } ], - "time": "2023-08-31T09:25:50+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", @@ -7935,16 +7871,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "2.3.2", + "version": "2.3.3", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "4800661a195e15783477d99f7f8f669a49793996" + "reference": "66499cd3c858642ded56dafb8fa0352057ca20dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/4800661a195e15783477d99f7f8f669a49793996", - "reference": "4800661a195e15783477d99f7f8f669a49793996", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/66499cd3c858642ded56dafb8fa0352057ca20dd", + "reference": "66499cd3c858642ded56dafb8fa0352057ca20dd", "shasum": "" }, "require": { @@ -8023,7 +7959,7 @@ "type": "github" } ], - "time": "2023-12-15T13:44:49+00:00" + "time": "2023-12-21T09:43:05+00:00" }, { "name": "symfony/yaml", diff --git a/config/cors.php b/config/cors.php index 8a39e6d..558369d 100644 --- a/config/cors.php +++ b/config/cors.php @@ -15,7 +15,7 @@ | */ - 'paths' => ['api/*', 'sanctum/csrf-cookie'], + 'paths' => ['api/*'], 'allowed_methods' => ['*'], diff --git a/config/sanctum.php b/config/sanctum.php deleted file mode 100644 index 35d75b3..0000000 --- a/config/sanctum.php +++ /dev/null @@ -1,83 +0,0 @@ - explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( - '%s%s', - 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', - Sanctum::currentApplicationUrlWithPort() - ))), - - /* - |-------------------------------------------------------------------------- - | Sanctum Guards - |-------------------------------------------------------------------------- - | - | This array contains the authentication guards that will be checked when - | Sanctum is trying to authenticate a request. If none of these guards - | are able to authenticate the request, Sanctum will use the bearer - | token that's present on an incoming request for authentication. - | - */ - - 'guard' => ['web'], - - /* - |-------------------------------------------------------------------------- - | Expiration Minutes - |-------------------------------------------------------------------------- - | - | This value controls the number of minutes until an issued token will be - | considered expired. This will override any values set in the token's - | "expires_at" attribute, but first-party sessions are not affected. - | - */ - - 'expiration' => null, - - /* - |-------------------------------------------------------------------------- - | Token Prefix - |-------------------------------------------------------------------------- - | - | Sanctum can prefix new tokens in order to take advantage of numerous - | security scanning initiatives maintained by open source platforms - | that notify developers if they commit tokens into repositories. - | - | See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning - | - */ - - 'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''), - - /* - |-------------------------------------------------------------------------- - | Sanctum Middleware - |-------------------------------------------------------------------------- - | - | When authenticating your first-party SPA with Sanctum you may need to - | customize some of the middleware Sanctum uses while processing the - | request. You may change the middleware listed below as required. - | - */ - - 'middleware' => [ - 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, - 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, - 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, - ], - -]; diff --git a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php deleted file mode 100644 index 81a7229..0000000 --- a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('password_reset_tokens'); - } -}; diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php deleted file mode 100644 index 249da81..0000000 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ /dev/null @@ -1,32 +0,0 @@ -id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php deleted file mode 100644 index e828ad8..0000000 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ /dev/null @@ -1,33 +0,0 @@ -id(); - $table->morphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); - $table->timestamp('expires_at')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('personal_access_tokens'); - } -}; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2023_12_26_213315_create_users_table.php similarity index 80% rename from database/migrations/2014_10_12_000000_create_users_table.php rename to database/migrations/2023_12_26_213315_create_users_table.php index 444fafb..9d95a5e 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2023_12_26_213315_create_users_table.php @@ -13,11 +13,11 @@ public function up(): void { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('first_name'); + $table->string('last_name'); $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); $table->string('password'); - $table->rememberToken(); + $table->string('profile_photo_path')->nullable(); $table->timestamps(); }); } From dccdf049e983e4948b24620b2196df18c5af9ddc Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Tue, 26 Dec 2023 23:39:03 +0100 Subject: [PATCH 5/6] Create model & seeder --- app/Models/User.php | 12 +++++------- database/factories/UserFactory.php | 16 +++------------- database/seeders/DatabaseSeeder.php | 9 +++------ database/seeders/UsersSeeder.php | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 database/seeders/UsersSeeder.php diff --git a/app/Models/User.php b/app/Models/User.php index 6bd3a59..3465623 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,14 +2,12 @@ namespace App\Models; -// use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; -use Illuminate\Notifications\Notifiable; class User extends Authenticatable { - use HasFactory, Notifiable; + use HasFactory; /** * The attributes that are mass assignable. @@ -17,9 +15,11 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', + 'first_name', + 'last_name', 'email', 'password', + 'profile_photo_path' ]; /** @@ -28,8 +28,7 @@ class User extends Authenticatable * @var array */ protected $hidden = [ - 'password', - 'remember_token', + 'password' ]; /** @@ -38,7 +37,6 @@ class User extends Authenticatable * @var array */ protected $casts = [ - 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 584104c..dd55781 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Str; /** * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User> @@ -24,21 +23,12 @@ class UserFactory extends Factory public function definition(): array { return [ - 'name' => fake()->name(), + 'first_name' => fake()->firstName(), + 'last_name'=> fake()->lastName(), 'email' => fake()->unique()->safeEmail(), - 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), - 'remember_token' => Str::random(10), + 'profile_photo_path' => fake()->imageUrl(480, 480, 'people', true) ]; } - /** - * Indicate that the model's email address should be unverified. - */ - public function unverified(): static - { - return $this->state(fn (array $attributes) => [ - 'email_verified_at' => null, - ]); - } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a9f4519..87f834a 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -12,11 +12,8 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // \App\Models\User::factory(10)->create(); - - // \App\Models\User::factory()->create([ - // 'name' => 'Test User', - // 'email' => 'test@example.com', - // ]); + $this->call([ + UsersSeeder::class + ]); } } diff --git a/database/seeders/UsersSeeder.php b/database/seeders/UsersSeeder.php new file mode 100644 index 0000000..48f82ac --- /dev/null +++ b/database/seeders/UsersSeeder.php @@ -0,0 +1,17 @@ +count(20)->create(); + } +} From 419d9c830e8ea9e51a25de319c6df17cfb3cc8b3 Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Wed, 27 Dec 2023 00:03:49 +0100 Subject: [PATCH 6/6] Add UserController and profile route --- app/Http/Controllers/UserController.php | 18 ++++++++++++++++++ resources/views/profile.blade.php | 14 ++++++++++++++ routes/web.php | 6 +++++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/UserController.php create mode 100644 resources/views/profile.blade.php diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..d142262 --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,18 @@ + User::all()->first() + ]); + } + +} diff --git a/resources/views/profile.blade.php b/resources/views/profile.blade.php new file mode 100644 index 0000000..4f45a23 --- /dev/null +++ b/resources/views/profile.blade.php @@ -0,0 +1,14 @@ + + + + + + + Maestro + + +

Profile

+

Hi, {{ $user->first_name . ' ' . $user->last_name }}

+

Your email is: {{ $user->email }}

+ + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index e3c2ee5..8d1db28 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,6 +13,10 @@ | */ +use App\Http\Controllers\UserController; + Route::get('/', function () { return view('welcome'); -}); \ No newline at end of file +}); + +Route::get('/profile', [UserController::class, 'show']); \ No newline at end of file