Quick actions

cmd+k|ctrl+k

Navigation

Languages

Multi Address Create - Laravel - Replicate

Snippet info

Language

Php

Visibility

public

Author

abdlkdrgndz

Created

2021-04-23T07:06:01.42045Z

Updated

2023-12-21T08:18:56.941074Z

<?php

use App\Models\Address;

// FIRST ADDRESS 
$shipping = Address::create([
    'type' => 'main',
    'line' => '123 Example Street',
    'city' => 'Victorville',
    'state' => 'CA',
    'postcode' => '12234',
]);

// SECOND ADDRESS 
$billing = $shipping->replicate()->fill([
    'type' => 'work'
]);

// CREATE 
$billing->save();
INFO