public function save($data, $taxRate = null)
{
if ($taxRate) {
// do nothing
} elseif (isset($data['public_id'])) {
$taxRate = TaxRate::scope($data['public_id'])->firstOrFail();
\Log::warning('Entity not set in tax rate repo save');
} else {
$taxRate = TaxRate::createNew();
}
$taxRate->fill($data);
$taxRate->save();
return $taxRate;
}
/** * @param UpdateTaxRateRequest $request * @param $publicId * @return \Illuminate\Http\Response */ public function update(UpdateTaxRateRequest $request, $publicId) { if ($request->action) { return $this->handleAction($request); } $data = $request->input(); $data['public_id'] = $publicId; $taxRate = $this->taxRateRepo->save($data, $request->entity()); return $this->itemResponse($taxRate); }