tadasei / laravel-contacts
A package that provides stubs for managing contact info associations with models
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/tadasei/laravel-contacts
Requires
- php: ^8.1.0
- illuminate/console: ^9.0|^10.0|^11.0
- illuminate/filesystem: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- illuminate/validation: ^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpstan/phpstan: ^1.10
- symfony/var-dumper: ^6.4
README
This package provides stubs for contacts association (with various contact methods) to Eloquent models.
Features
- Quickly generate contacts migrations, models, factories and enums.
- Customize and extend generated code to fit your project's needs.
- Improve development efficiency by eliminating repetitive tasks.
Installation
You can install the package via Composer by running:
composer require tadasei/laravel-contacts --dev
Publishing contacts handling utilities
To publish contacts handling utilities, use the following command:
php artisan contacts:install
Configuring The Country Model
This package references an App\Models\Country model and requires manual supply of its implementation to add phone code support through a phone_code attribute for the following contact method types:
landlinemobilefax
To use a different model, edit App\Models\ContactMethod and Database\Factories\ContactMethodFactory accordingly.
Configuring Contactable Models
To extend or define which models are considered contactable, edit:
App\Enums\ContactableType: Add your model class names to this enum.Database\Factories\ContactFactory: Customize logic to generate contacts for your specific model types.
This allows full flexibility in defining how your application links contacts to models.
Running migrations
To create the related contacts and contact_methods tables, run the generated migrations using the following command:
php artisan migrate
Usage:
$contact = $customer->contacts()->create([ 'name' => 'John Doe', ]); $contact->contactMethods()->create([ 'type' => 'email', 'value' => 'john@example.com', ]);
Customization
The generated code serves as a starting point. You can customize and extend it according to your project's requirements. Modify the generated utilities as needed.
Contributing
Contributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue on the GitHub repository.
License
This package is open-source software licensed under the MIT license.