PHP code example of maa-solutions / simple-address

1. Go to this page and download the library: Download maa-solutions/simple-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/ */

    

maa-solutions / simple-address example snippets


class MyModel extends Model implements Addressable
{
    use HasAddresses;

    ...
}

use MaaSolutions\SimpleAddress\Facades\SimpleAddress;

...

public function create(Request $request)
{
    $validated_address = SimpleAddress::validate($request->all());

    $myModel = MyModel::create($request->validated());

    SimpleAddress::create(for: $myModel, with: $validated_address);
}

public function update(Request $request, MyModel $myModel)
{
    SimpleAddress::update(for: $myModel, with: $request->all());
}