PHP code example of webard / nova-zadarma

1. Go to this page and download the library: Download webard/nova-zadarma 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/ */

    

webard / nova-zadarma example snippets


use Webard\NovaZadarma\NovaZadarmaTool;

public function tools()
{
    return [
        ...
        NovaZadarmaTool::make(),
    ];
}

use Propaganistas\LaravelPhone\Casts\E164PhoneNumberCast;
use Webard\NovaZadarma\Traits\HasPhoneCalls;

class User extends Authenticatable {
    use HasPhoneCalls;

    protected $fillable = [
        ...
        'zadarma_sip',
        'phone_number'
    ];

     protected function casts(): array
    {
        return [
            ...
            'phone_number' => E164PhoneNumberCast::class,
        ];
    }
}

use Webard\NovaZadarma\Nova\Fields\UserPhoneCalls;

class User extends Resource {
    public function fields(NovaRequest $request)
    {
        return [
            ...
            Text::make(__('Zadarma SIP'), 'zadarma_sip')
                ->sortable()
                ->nullable()
                ->rules('nullable', 'max:4'),

            Text::make(__('Phone Number'), 'phone_number')
                ->sortable()
                ->rules('nullable', 'max:20', 'phone'),

            UserPhoneCalls::make(),
        ];
    }
}

use Webard\NovaZadarma\Nova\Actions\MakePhoneCall;

class User extends Resource {
    public function actions(NovaRequest $request)
    {
        return [
            ...
            MakePhoneCall::make()
                ->sole()
        ];
    }
}

return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {

        $middleware->validateCsrfTokens(except: [
            '/nova-vendor/webard/nova-zadarma/webhook',
        ]);
        
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })
    ->create();

'ignore-paths' => [
    'nova-vendor/webard/nova-zadarma/webhook'
]
sh
php artisan vendor:publish --provider="Webard\NovaZadarma\NovaZadarmaServiceProvider" --tag=config
sh
php artisan vendor:publish --provider="Webard\NovaZadarma\NovaZadarmaServiceProvider" --tag=migrations