PHP code example of rinvex / contacts

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

    

rinvex / contacts example snippets


// Get instance of your model
$user = new \App\Models\User::find(1);

// Create a new contact
$user->contacts()->create([
    'given_name' => 'Abdelrahman',
    'family_name' => 'Omran',
    'title' => 'Software Architect',
    'organization' => 'Rinvex',
    'email' => '[email protected]',
    'phone' => '+201228160181',
    'source' => 'website',
    'method' => 'call',
    'country_code' => 'eg',
    'language_code' => 'en',
    'birthday' => '1987-06-18',
    'gender' => 'male',
]);

// Create multiple new contacts
$user->contacts()->createMany([
    [...],
    [...],
    [...],
]);

// Find an existing contact
$contact = app('rinvex.contacts.contact')->find(1);

// Update an existing contact
$contact->update([
    'email' => '[email protected]',
]);

// Delete contact
$contact->delete();

// Alternative way of contact deletion
$user->contacts()->where('id', 123)->first()->delete();

// Get relative contacts collection
$user->relatives;

// Get relative contacts query builder
$user->relatives();

// Get back relative contacts collection
$user->backRelatives;

// Get back relative contacts query builder
$user->backRelatives();

// Get attached contacts collection
$user->contacts;

// Get attached contacts query builder
$user->contacts();

    php artisan rinvex:migrate:contacts