🔌
Laravel API Auth Builder
  • 💎Overview
  • 🔨Install
  • 🔦Using
  • 💿API Collection
Powered by GitBook
On this page
  • Command Line
  • Extend Class

Was this helpful?

Using

How to use this package on your project?

you can use our package with 2 ways

Command Line

you can generate a full option API by just using this command

php artisan auth:generate

it will ask you about some components to build auth for you.

NOTE

if you select OTP to true you must inject some cols to your table like this schema

otp_code string null
otp_active_at timestamp null
is_active bool false

Extend Class

if you have a ready controller and you don't need to use our command just extend this controller from our class

io3x1\LaravelAuthBuilder\Services\BuildAuth

and setting the __construct like

public function __construct()
{
    $this->validation = [
        "create" => [
            "name" => "required|max:191|string",
            "email" => "required|email|max:191|string|unique:users,email",
        ],
        "update" => [
            "name" => "sometimes|max:191|string",
            "email" => "sometimes|email|max:191|string|unique:users,email",
        ]
    ];
    $this->loginBy = "email";
    $this->loginType = "email";
    $this->model = "App\Models\User";
    $this->guard = "web";
    $this->otp = 0;
}

and on your api.php route list add this line

\io3x1\LaravelAuthBuilder\Helpers\AuthRoutes::load('users', App\Http\Controllers\API\Auth\UsersAuthController::class);

when users is the guard's name and other attr is the controller class

Last updated 2 years ago

Was this helpful?

🔦