LaravelPackages.net
Acme Inc.
Toggle sidebar
zoparga/laravel-company-information

Add many address to many model with a single trait. E.g.: many shipping address for a customer.

12
0
0.8.1
About zoparga/laravel-company-information

zoparga/laravel-company-information is a Laravel package for add many address to many model with a single trait. e.g.: many shipping address for a customer.. It currently has 0 GitHub stars and 12 downloads on Packagist (latest version 0.8.1). Install it with composer require zoparga/laravel-company-information. Discover more Laravel packages by zoparga or browse all Laravel packages to compare alternatives.

Last updated

Add many address to many model with a single trait. E.g.: many shipping address for a customer.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require zoparga/laravel-company-information

You can publish and run the migrations with:

php artisan vendor:publish --provider="zoparga\CompanyInformation\CompanyInformationServiceProvider" --tag="company-information-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="zoparga\CompanyInformation\CompanyInformationServiceProvider" --tag="laravel-company-information-config"

This is the contents of the published config file:

Usage

  • publish migration file
  • migrate
  • add trait to model
  • use it

Prepare model

use zoparga\CompanyInformation\Traits\CompanyInformationeableTrait;

class {{model}} extends Model { use CompanyInformationeableTrait; }


$model = \App\Models\Model::find(1);

$model->companyInformations()->create([
    'full_name' => 'YOUR INFORMATION',
    'main_address' => 'YOUR INFORMATION',
    'bank_bic' => 'YOUR INFORMATION',
    'bank_iban' => 'YOUR INFORMATION',
    'vat' => 'YOUR INFORMATION',
]);

$companyInformationId = 1;

$model->updateCompanyInformation($companyInformationId, [
    'full_name' => 'YOUR INFORMATION',
    'main_address' => 'YOUR INFORMATION',
    'bank_bic' => 'YOUR INFORMATION',
    'bank_iban' => 'YOUR INFORMATION',
    'vat' => 'YOUR INFORMATION',
]);

Get the addresses, order by ID - desc
Or you can limit it here
$model->getLatestCompanyInformationes()->get();

Or you can limit it here
$model->getLatestCompanyInformationes()->limit(3)->get();

Of course you can get last created address
$model->getLastCompanyInformation();


Testing

composer test

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.

Comments