inmanturbo/contacts

一个用于处理Laravel中联系人类别简单工具包

v2.1.6 2024-01-31 20:47 UTC

README

一个用于处理Laravel中联系人类别简单工具包

安装

您可以通过composer安装此包

composer require inmanturbo/laravel-contacts-manager

您可以使用以下命令发布和运行迁移

php artisan vendor:publish --tag="contacts-manager-migrations"
php artisan migrate

使用方法

//Create a contact
Contact::create([
    'first_name' => '...',
    'last_name' => '...',
    'business_name' => '...',
    'address' => '...',
    'zip_code' => '...',
    'country_code' => '...',
    'email' => '...',
    'mobile' => '...',
    'phone' => '...',
    'vat_number' => '...',
    'notes' => '...',
    'type' => '...' // MANDATORY: 'private' or 'business',
]);

//Create a contact list
ContactList::create([
    'user_id' => '1' //desired user id
    'name' => 'this is the list name'
]);

//attach a contact to a list and viceversa

$contact->lists()->attach($listId);
$list->contacts()->attach($contactId);

//fetch contacts from a list

$list->contacts;

//fetch all lists connected to a contact

$contact->lists;

//Contact and ContactList are taggable. Feel free to use tags as you desire in your flow
//Tags are meant to be a flexible way to categorize your model.
$tag = Tag::create(['name' => 'Test tag', 'user_id' => $user->id]);

$contact->tags()->attach($tag->id);

$contactList->tags()->attach($tag->id);

//Retrive taggable elements from a tag

$tag->contacts; //returns a collection of Contacts
$tag->contactLists; //returns a collection of ContactList

测试

composer test

变更日志

有关最近变更的更多信息,请参阅变更日志

贡献

有关详细信息,请参阅贡献指南

安全漏洞

有关如何报告安全漏洞的详细信息,请审查我们的安全策略

致谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件