PHP code example of zoparga / laravel-contact-information

1. Go to this page and download the library: Download zoparga/laravel-contact-information 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/ */

    

zoparga / laravel-contact-information example snippets



$model = \App\Models\Model::find(1);

$model->contactInformations()->create([
    'type' => 'phone',
    'information' => '+361123123',
    'primary' => 1,
]);

$model->contactInformations()->create([
    'type' => 'web',
    'information' => 'info.xyz',
    'primary' => 1,
]);

$contactInformationId = 1;

$model->updateContactInformation($contactInformationId, [
    'type' => 'phone',
    'information' => '+361123123',
    'primary' => 0,
]);


Get the addresses, order by ID - desc
Or you can limit it here
$model->getLatestContactInformationes()->get();

Or you can limit it here
$model->getLatestContactInformationes()->limit(3)->get();

Of course you can get last created address
$model->getLastContactInformation();


bash
php artisan vendor:publish --provider="zoparga\ContactInformation\ContactInformationServiceProvider" --tag="contact-information-migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="zoparga\ContactInformation\ContactInformationServiceProvider" --tag="laravel-contact-information-config"