public function save(array $input) { if (isset($input['id'])) { $id = $input['id']; /* @var ApiKey $apikey */ $apikey = ApiKey::find($id); $apikey->update($input); $apikey->save(); return $apikey; } else { $apikey = ApiKey::firstOrNew($input); $apikey->save(); return $apikey; } }