Skip to content

Rinvex Contacts is a polymorphic Laravel package, for contact management system. You can add contacts to any eloquent model with ease.

License

Notifications You must be signed in to change notification settings

craigmcmeechan/contacts

 
 

Repository files navigation

Rinvex Contacts

Rinvex Contacts is a polymorphic Laravel package, for contact management system. You can add contacts to any eloquent model with ease.

Packagist VersionEye Dependencies Scrutinizer Code Quality Code Climate Travis SensioLabs Insight StyleCI License

Installation

  1. Install the package via composer:

    composer require rinvex/contacts
  2. Execute migrations via the following command:

    php artisan migrate --path="vendor/rinvex/contacts/database/migrations"
    
  3. Optionally you can publish migrations and config files by running the following commands:

    // Publish migrations
    php artisan vendor:publish --tag="rinvex-contacts-migrations"
    
    // Publish config
    php artisan vendor:publish --tag="rinvex-contacts-config"
  4. Done!

Usage

Create Your Model

Simply create a new eloquent model, and use \Rinvex\Contacts\HasContacts trait:

namespace App\Models;

use Rinvex\Contacts\HasContacts;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use HasContacts;
}

Manage Your Contacts

$user = new \App\Models\User();

// Create a new contact
$user->contacts()->create([
    'name_prefix' => 'Mr.',
    'first_name' => 'Abdelrahman',
    'middle_name' => 'Hossam M. M.',
    'last_name' => 'Omran',
    'name_suffix' => null,
    'job_title' => 'Software Architect',
    'email' => 'me@omranic.com',
    'phone' => '+201228160181',
    'source' => 'website',
    'method' => 'call',
    'country_code' => 'eg',
    'language_code' => 'en',
    'birthday' => '1987-06-18',
    'gender' => 'm',
    'is_active' => 1,
]);

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

// Find an existing contact
$contact = \Rinvex\Contacts\Contact::find(1);

// Update an existing contact
$contact->update([
    'email' => 'iOmranic@gmail.com',
]);

// 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();

Changelog

Refer to the Changelog for a full history of the project.

Support

The following support channels are available at your fingertips:

Contributing & Protocols

Thank you for considering contributing to this project! The contribution guide can be found in CONTRIBUTING.md.

Bug reports, feature requests, and pull requests are very welcome.

Security Vulnerabilities

If you discover a security vulnerability within this project, please send an e-mail to help@rinvex.com. All security vulnerabilities will be promptly contacted.

About Rinvex

Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity.

License

This software is released under The MIT License (MIT).

(c) 2016-2017 Rinvex LLC, Some rights reserved.

About

Rinvex Contacts is a polymorphic Laravel package, for contact management system. You can add contacts to any eloquent model with ease.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%