agencyActivity()->delete(); foreach ($permissions as $permission) { list($sector, $code) = explode('|', $permission); $dataForms = [ 'agency_id' => $agency->id, 'form_sector' => $sector, 'form_code' => $code ]; $this->create($dataForms, AgencyActivity::class); } DB::commit(); return true; } catch (\Exception $e) { DB::rollBack(); throw $e; } } }