aecor/contactable
Composer 安装命令:
composer require aecor/contactable
包简介
Add multiple contacts for a User
关键字:
README 文档
README
Installation
You can install the package via composer:
composer require aecor/contactable
You can publish and run the migrations with:
php artisan vendor:publish --provider="Aecor\Contact\ContactServiceProvider" --tag="migrations" php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Aecor\Contact\ContactServiceProvider" --tag="config"
This is the contents of the published config file:
return [ 'table-name' => 'contacts' ];
Usage and few examples
Prepare your model
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Aecor\Contact\Traits\HasContact; class YourModel extends Model { use HasContact; }
Get instance of your model
$user = \App\Models\User::find(1);
Add a single contact
$user->addContact([ 'type' => 'phone', 'value' => '9999999999', 'custom_attributes' => [ 'sub_type' => 'office' ], // Optional field 'order_column' => 1 // Optional field ]);
Add multiple contacts
$user->addManyContacts([ [ 'type' => 'phone', 'value' => '9999999999', ], [ 'type' => 'mobile', 'value' => '8888888888', ], [ 'type' => 'email', 'value' => 'john@example.com', ], ]);
Get all contacts
$user->contacts;
Get contacts with condition
$user->contacts()->where('type', 'mobile')->get();
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 110
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-20