2017 © Pedro Peláez
 

library laravel-mobile-passport

:description

image

alive2212/laravel-mobile-passport

:description

  • Saturday, July 28, 2018
  • by Alive2212
  • Repository
  • 1 Watchers
  • 1 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

LaravelMobilePassport

Latest Version on Packagist ![Total Downloads][ico-downloads] Build Status StyleCI, (*1)

This is where your description should go. Take a look at contributing.md to see a to do list., (*2)

Installation

Via Composer, (*3)

``` bash $ composer require alive2212/laravel-mobile-passport, (*4)

add to service provider 'config/app.php'
```php
    'providers' => [
        ...

        /*
         * Authentication service
         */
        Alive2212\LaravelMobilePassport\LaravelMobilePassportServiceProvider::class,
    ],

if use Lumen add following service provider at then end of 'bootstrap/app.php', (*5)

$app->register(Alive2212\LaravelMobilePassport\LaravelMobilePassportServiceProvider::class);

$app->router->group([
    'namespace' => 'Alive2212\LaravelMobilePassport\Http\Controllers',
], function ($router) {
    require Alive2212\LaravelMobilePassport\LaravelMobilePassport::getDir() .
        '/lumen_routes.php';
});

migrate all database, (*6)

$ php artisan migrate

add following code into AuthServiceProvider in 'boot' method, (*7)

public function boot()
{
    $this->registerPolicies();

    Passport::routes();

    LaravelMobilePassport::initPassportTokenCan();

    LaravelMobilePassportSingleton::$otpCallBack = function (
        Request $request,
        User $user,
        AliveMobilePassportDevice $device,
        $token
    ) {
        // dispatch send sms job here to send notification

    };


    LaravelMobilePassportSingleton::$otpConfirmCallBack = function (
        Request $request,
        User $user,
        PersonalAccessTokenResult $token,
        ResponseModel $response
    ) {
        // put something here like update user name with request fields

    };

}
  • tip: if ENV_DEBUG in .env file set to false don't return any data in register by token

add 'phone_number' & 'country_code' into model $fillable variable:, (*8)

    protected $fillable = [
        'name',
        'email',
        'password',
        'phone_number',
        'country_code',
    ];

publish vendor files with following command:, (*9)

php artisan vendor:publish --tag laravel-mobile-passport.lang
php artisan vendor:publish --tag laravel-mobile-passport.config
php artisan vendor:publish --tag laravel-mobile-passport.migrations
php artisan vendor:publish --tag laravel-mobile-passport.models

User model must be extended from BaseAuthModel, (*10)

In the next step you should install following package and it's version related to your laravel version. * phoenix/eloquent-meta * fico7489/laravel-pivot, (*11)

Add flowing code into app\User.php, (*12)

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function roles()
    {
        return $this->belongsToMany(
            AliveMobilePassportRole::class,
            'alive_mobile_passport_role_user',
            'user_id',
            'role_id'
        );
    }

Finally run following command to install passport dependency, (*13)

$ art passport:install

Optional for add routes you can put following into boot method at AppServiceProvider, (*14)

// add mobile passport routes
LaravelMobilePassport::routes(null,['middleware'=>'cors']);

Usage

1- create roles what you want in to alive_mobile_passport_roles *tip: title of roles must unique, (*15)

You can use following to get current user scopes, (*16)

$request['access_token'])

Change log

Please see the changelog for more information on what has changed recently., (*17)

Testing

bash $ composer test, (*18)

Relation of this package with another one is: * array helper -> nothing * laravel excel helper -> nothing * laravel onion pattern -> nothing * laravel query helper -> nothing * laravel reflection helper -> nothing * laravel request helper -> nothing * laravel string helper -> nothing * laravel smart response -> array helper * laravel smart restful -> laravel excel helper, laravel onion pattern, laravel query helper, laravel reflection helper, laravel smart response, laravel string helper * laravel passport auth -> laravel smart restful, (*19)

Contributing

Please see contributing.md for details and a todolist., (*20)

Security

If you discover any security related issues, please email author email instead of using the issue tracker., (*21)

Credits

License

license. Please see the license file for more information., (*22)

The Versions