MahmoudMansour
Importer Not Working
solved finally
public function resolveRecord(): ?MedicalSource
{
$medicalSource = new MedicalSource();
// Define the keys for discounts data
$discountsKeys = ['statement', 'surgical', 'emergency', 'labs', 'internal', 'other', 'xrays', 'pathology', 'local', 'imported', 'cosmetic'];
// Initialize the discounts data array
$discountsData = [];
// Loop through the discounts keys
foreach ($discountsKeys as $key) {
// If the key exists in $this->data, add it to $discountsData and remove it from $this->data
if (isset($this->data[$key])) {
$discountsData[$key] = $this->data[$key];
unset($this->data[$key]);
}
}
// Fill the MedicalSource instance with data and save it
$medicalSource->fill($this->data)->save();
// Create the Discounts record
$medicalSource->discounts()->create($discountsData);
return $medicalSource;
}
public function resolveRecord(): ?MedicalSource
{
$medicalSource = new MedicalSource();
// Define the keys for discounts data
$discountsKeys = ['statement', 'surgical', 'emergency', 'labs', 'internal', 'other', 'xrays', 'pathology', 'local', 'imported', 'cosmetic'];
// Initialize the discounts data array
$discountsData = [];
// Loop through the discounts keys
foreach ($discountsKeys as $key) {
// If the key exists in $this->data, add it to $discountsData and remove it from $this->data
if (isset($this->data[$key])) {
$discountsData[$key] = $this->data[$key];
unset($this->data[$key]);
}
}
// Fill the MedicalSource instance with data and save it
$medicalSource->fill($this->data)->save();
// Create the Discounts record
$medicalSource->discounts()->create($discountsData);
return $medicalSource;
}
2 replies