PHP code example of kwidoo / laravel-contacts

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

    

kwidoo / laravel-contacts example snippets


namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Kwidoo\Contacts\Contracts\Contactable;
use Kwidoo\Contacts\Traits\HasContacts;

class User extends Authenticatable implements Contactable
{
    use HasContacts;

    // Your model implementation
}

use Kwidoo\Contacts\Contracts\ContactService;

// Typically, $this->user is your model that implements Contactable
$contactService = app(ContactService::class, [
    'model' => $this->user
]);

$uuid = $contactService->create('email', '[email protected]');
// Returns the UUID (or ID) of the newly created contact

$user->contacts; // returns a collection of Contact models
bash
   php artisan vendor:publish --provider="Kwidoo\Contacts\ContactServiceProvider" --tag="config"
   
bash
php artisan vendor:publish --provider="Kwidoo\Contacts\ContactServiceProvider" --tag="migrations"
php artisan migrate