socoladaica/laravel-api

2.0 2024-12-31 02:23 UTC

This package is auto-updated.

Last update: 2024-12-31 02:24:43 UTC


README

Latest Version on Packagist

GitHub Tests Action Status

GitHub Code Style Action Status

Total Downloads

Installation

You can install the package via composer:

composer require socoladaica/laravel-api

You can publish and run the migrations with:

php artisan vendor:publish --provider="SocolaDaiCa\LaravelApi\Providers\LaravelApiServiceProvider" --tag="migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="SocolaDaiCa\LaravelApi\Providers\LaravelApiServiceProvider" --tag="config"

Optionally, you can publish the views using

--provider="SocolaDaiCa\LaravelApi\Providers\LaravelApiServiceProvider" --tag="views"

Usage

Route::group([
    'prefix' => 'v1/admin',
    'namespace' => 'Api\V1\Admin',
], function () {
    Route::authApi([
        'login' => true,
        'reset' => false,
    ]);
});

# create controller
Auth/LoginController
php artisan jwt:secret
https://jwt-auth.readthedocs.io/en/develop/quick-start/
class User extends Authenticatable implements JWTSubject {
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [];
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

MIT. Please see LICENSE File for more information.