1. Go to this page and download the library: Download lecturize/laravel-addresses 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/ */
lecturize / laravel-addresses example snippets
" "lecturize/laravel-addresses": "^1.1"
}
namespace App\Models;
use Lecturize\Addresses\Traits\HasAddresses;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasAddresses;
// ...
}
$post = Post::find(1);
$post->addAddress([
'street' => '123 Example Drive',
'city' => 'Vienna',
'post_code' => '1110',
'country' => 'AT', // ISO-3166-2 or ISO-3166-3 country code
'is_primary' => true, // optional flag
]);
$address = [
'street' => '123 Example Drive',
'city' => 'Vienna',
'post_code' => '1110',
'country' => 'AT', // ISO-3166-2 or ISO-3166-3 country code
'is_primary' => true, // optional flag
];
$post->addAddress($address);
$address = $post->addresses()->first(); // fetch the address
$post->updateAddress($address, $new_attributes);
$address = $post->addresses()->first(); // fetch the address
$post->deleteAddress($address); // delete by passing it as argument
$post->flushAddresses();
namespace App\Models;
use Lecturize\Addresses\Traits\HasContacts;
use Illuminate\Database\Eloquent\Model;
class Team extends Model
{
use HasContacts;
// ...
}