PHP code example of zoparga / laravel-multi-address
1. Go to this page and download the library: Download zoparga/laravel-multi-address library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zoparga / laravel-multi-address example snippets
$model = \App\Models\Model::find(1);
$model->multiaddresses()->create([
'type' => 'YOUR VALUE',
'country' => 'YOUR VALUE',
'zip' => 'YOUR VALUE',
'city' => 'YOUR VALUE',
'street' => 'YOUR VALUE',
'address_longitude' => 'YOUR VALUE',
'address_latitude' => 'YOUR VALUE',
]);
$multiAddressId = 1;
$model->updateMultiAddress($multiAddressId, [
'type' => 'YOUR VALUE',
'country' => 'YOUR VALUE',
'zip' => 'YOUR VALUE',
'city' => 'YOUR VALUE',
'street' => 'YOUR VALUE',
'address_longitude' => 'YOUR VALUE',
'address_latitude' => 'YOUR VALUE',
]);
Get the addresses, order by ID - desc
Or you can limit it here
$model->getLatestMultiAddresses()->get();
Or you can limit it here
$model->getLatestMultiAddresses()->limit(3)->get();
Of course you can get last created address
$model->getLastMultiAddress();