PHP code example of ezavalishin / vkma

1. Go to this page and download the library: Download ezavalishin/vkma library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ezavalishin / vkma example snippets


'guards' => [
    ...
    'vkma' => [
        'driver' => 'vkma'
    ]
], 

$user = Auth::user();

use Illuminate\Foundation\Auth\User as Authenticatable;

use ezavalishin\VKMA\Contracts\VKMAUserInterface;
use ezavalishin\VKMA\Traits\VKMAUserable;

class User extends Authenticatable implements VKMAUserInterface
{
    use VKMAUserable;

    public function vkFieldsMap(): array
    {
        return [
            //db field => vk field name

            'first_name' => 'first_name',
            'last_name' => 'last_name',
            'birth_date' => 'bdate',
            'city_id' => 'city',
            'country_id' => 'country'
        ];
    }
}

dispatch(new \ezavalishin\VKMA\Jobs\FillUser($user));

use Illuminate\Foundation\Auth\User as Authenticatable;
use ezavalishin\VKMA\Contracts\VKMAUserInterface;
use ezavalishin\VKMA\Traits\VKMAUserable;

use ezavalishin\VKMA\Jobs\FillUser;

class User extends Authenticatable implements VKMAUserInterface
{
    use VKMAUserable;
    
    ...

    public static function booted()
    {
        self::created(static function(self $model) {
            dispatch(new FillUser($model));
        });
    }
}

use Illuminate\Foundation\Auth\User as Authenticatable;
use ezavalishin\VKMA\Contracts\VKMAUserInterface;
use ezavalishin\VKMA\Traits\VKMAUserable;

class User extends Authenticatable implements VKMAUserInterface
{
    use VKMAUserable;
    
    ...

    public function parseCountry($value)
    {
        return $value['id'];
    }

    public function parseCity($value)
    {
        return $value['id'];
    }
}
 bash
$ php artisan vendor:publish --provider="ezavalishin\VKMA\VKMAServiceProvider"