From ff80d03d1f62ae711ccfaf662819eb3de0da362f Mon Sep 17 00:00:00 2001 From: Imani Manyara Date: Sat, 3 Oct 2026 05:24:29 -0400 Subject: [PATCH] Add a Quick start to the README The docs standard makes a Quick start required: one runnable example that shows what the package does in use, right after Install, pointing on to the full walkthrough. Every symbol in the example was checked against src/, config/ and routes/ before it was written down. --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index a4ac97b..fae4cd3 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,28 @@ php artisan vendor:publish --tag=laranail::authkit-config See [installation](docs/installation.md) for the full walkthrough. +## Quick start + +```php +use Illuminate\Http\Request; +use Simtabi\Laranail\AuthKit\Contracts\AttemptEmailPasswordLoginInterface; +use Simtabi\Laranail\AuthKit\Contracts\LoginUserInterface; +use Simtabi\Laranail\AuthKit\Enums\AuthStatus; + +public function store(Request $request, AttemptEmailPasswordLoginInterface $attempt, LoginUserInterface $login) +{ + $result = $attempt->execute(request: $request, guard: 'web'); + + return match ($result->status) { + AuthStatus::Passed => tap(redirect()->intended('/dashboard'), fn () => $login->execute($result->user, 'web')), + AuthStatus::Failed => back()->withErrors(['email' => 'Invalid credentials.']), + AuthStatus::Throttled => abort(429), + }; +} +``` + +The full walkthrough is in [Getting started](docs/getting-started.md); everything else is in the [documentation index](#documentation). + ## Documentation Full documentation: