$params =
$this->
Request()->
getParams();
unset($params['action'
]);
$repository =
$this->
get('models'
)->
getRepository(Payment::
class);
$existingModel =
$repository->
findByName($params['name'
]);
if ($existingModel) { throw new ORMException('The name is already in use.'
);
} if ($params['source'
] == 0
) { $params['source'
] = null;
} $paymentModel =
new Payment();
$countries =
$params['countries'
] ??
[];
$countryArray =
[];
foreach ($countries as $country) { $countryArray[] =
$this->
get('models'
)->
find(Country::
class,
$country['id'
]);
} $params['countries'
] =
$countryArray;
$shops =
$params['shops'
] ??
[];
$shopArray =
[];
foreach ($shops as $shop) { $shopArray[] =
$this->
get('models'
)->
find(Shop::
class,
$shop['id'
]);
}