1. Go to this page and download the library: Download oguzhankrcb/datamigrator 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/ */
use App\Models\Order;
use App\Models\Invoice;
use Oguzhankrcb\DataMigrator\Facades\DataMigrator;
// Define the fields to transfer from Order to Invoice
$toModelPrototype = [
'invoice_number' => '[order_number]',
'customer_name' => '[customer->name]',
'customer_email' => '[customer->email]',
'total_amount' => '[amount]',
'total_amount_with_currency' => '[amount]€',
];
// Transfer the data from Order to Invoice
DataMigrator::transferAllDataFromModelToModel(Invoice::class, $toModelPrototype, Order::class);
use App\Models\Order;
use App\Models\Invoice;
use Oguzhankrcb\DataMigrator\Facades\DataMigrator;
// Define the fields to transfer from Order to Invoice
$toModelPrototype = [
'invoice_number' => '[order_number]',
'customer_name' => '[customer->name]',
'customer_email' => '[customer->email]',
'total_amount' => '[amount]',
'total_amount_with_currency' => '[amount]€',
];
$orderInstance = Order::find(1);
// Transfer the data from Order to Invoice
$transferedModel = DataMigrator::transferDataModelToModel(Invoice::class, $toModelPrototype, $orderInstance);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.